The open
handler’s parameter gets a list of alias
objects1. The curly braces ({}
) in your error message indicate that the error happend while it was trying to operate on a list object.
Thus, you need to use something like set FolderPath to first item of the_dropped_folder
to work with a single item instead of the list (and probably give the parameter a plural name while you are at it so it “reads better”). That should let your set ParentPath to container of FolderPath
statement work properly.
The next statement will probably fail though. ParentPath
will be a Finder folder
object which does not have a POSIX path
property. Usually the easiest way around this problem is to have Finder convert its item
object (folder
is a subclass of item
) into an alias
object and then extract its POSIX path
(alias
objects do have a POSIX path
property).
If you put all this together, you might end up with something like this:
on open someDroppedAliases
set theAlias to first item of someDroppedAliases
tell application "Finder"
set parentFolder to container of theAlias
set parentFolderAlias to parentFolder as alias
end tell
set parentFolderPath to POSIX path of parentFolderAlias
display dialog "Path of container:" default answer parentFolderPath
end open
Without all the intermediate variables:
on open someDroppedAliases
tell application "Finder" to ¬
set parentFolderPath to POSIX path of ¬
(container of first item of someDroppedAliases as alias)
display dialog "Path of container:" default answer parentFolderPath
end open
Or, with System Events (whose item
objects actually have a POSIX path
property):
on open someDroppedAliases
tell application "System Events" to ¬
set parentFolderPath to POSIX path of ¬
container of first item of someDroppedAliases
display dialog "Path of container:" default answer parentFolderPath
end open
Note: Nothing in my versions (or in your original formulation) is specific to processing folders. The same program will process a dropped file and yield its container.
1
Technically they are «class bmrk»
objects in Snow Leopard, which seem to work mostly like proper alias
objects (though there may be some differences from true alias
objects).