Get enclosing folder from a file object

Does anyoen know how to get the folder of a file? I am trying to make a droplet that takes a file and stuffs it into the same folder and then uses the full path name to the folder to acces the stuffed file.

I am sure someone must have done this before.

Thanks for any help

James

The easiest way of doing this is to ask the Finder for the file’s ‘container’

set theFIle to (choose file)
tell application "Finder"
   set theFolder to container of file theFile
end tell

Thanks for that. Could anyone tell me why this doesn’t work? I’ve now got the folder but Dropstuff won’t actually stuff it.

tell application “Finder”
set file_name to (choose file)
set destination_folder to container of file fileList
end tell
tell application “DropStuff”
activate
stuff file_name into destination_folder with format StuffItX
quit “DropStuff”
end tell

Possible because you’re telling DropStuff:

stuff file_name into destination_folder with format StuffItX

where:

set destination_folder to container of file fileList

However, what is fileList? it’s not defined anywhere in your code posted here. Maybe you meant to write:

set destination_folder to container of file file_name ?

Thanks for your help. I actually discovered that I needed to write

set destination_folder to container of file fileList as alias

Filelist is just a single file so it does work now. I find addressing files very confusing in Applescript!