how the heck do i get the path of the file when dropped onto a droplet!
thanks in advance
on open this_file
getFilename(this_file)
end open
on getFilename(this_file)
tell application "Finder"
activate
set the item_path to (the path of this_file) as text
end tell
end getFilename
: how the heck do i get the path of the file when dropped onto a
: droplet!
: thanks in advance
:
: on open this_file
: getFilename(this_file)
: end open
: on getFilename(this_file)
: tell application “Finder”
: activate
: set the item_path to (the path of this_file) as text
: end tell
: end getFilename
this_file is the path of your file. if you drop more than one file, this_file is now a list, each item is a path to one of the file you have dropped
: how the heck do i get the path of the file when dropped onto a
: droplet!
: thanks in advance
:
: on open this_file
: getFilename(this_file)
: end open
: on getFilename(this_file)
: tell application “Finder”
: activate
: set the item_path to (the path of this_file) as text
: end tell
: end getFilename
:
When a file is dropped onto the droplet, this_file will store the path to the file as an alias.
To get the name of this_file, try this (from Standard Additions):
on open this_file
set fileName to name of (info for (this_file as string))
end open
: this_file is the path of your file. if you drop more than one
: file, this_file is now a list, each item is a path to one of
: the file you have dropped
: Le Stang Jean-Baptiste
Even if you only drop one file “this_file” will be a list, a list of one item, the contents of which is an alias reference to your file. You need to extract the reference from the list before processing it as an alias. The Finder can’t find the name of a list because a list is not a Finder object.