easy question

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

Le Stang Jean-Baptiste

When an item or items is dropped on droplet, the result is a list, not a file specification or string or alias. So:

on open fl
	set x to item 1 of fl
	tell application "Finder" to set n to name of x
	display dialog n
end open

but you may want to test if the dropped items are files or folders before processing them.

: 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

Later,

Rob J

got it.

: 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.

Marc K. Myers
Marc@AppleScriptsToGo.com
AppleScriptsToGo
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[2/28/02 7:01:17 PM]