get folder of selected item

In my mind, it should be as simple as this:


tell application "Finder"
	set theFiles to selection
	get folder of selection
end tell

but I get an error that says “Can’t get folder of selection”

I know it’s just some stupid context thing that my brain doesn’t want to grasp today. Help please?

Model: PM G5
Browser: Firefox 3.6.17
Operating System: Mac OS X (10.4)

Hi,

selection is always a list, so retrieve the folder of the first item


tell application "Finder"
	set theFiles to selection
	if theFiles is not {} then
		get folder of item 1 of theFiles
	end if
end tell

Prompt and helpful as always. Thank you Stefan.