Bizzare behavior of Properties of Finder Items

I admit that I haven’t used AppleScript for a few years, but I baffled by the behavior of the properties of finder items, specifically the name. I was working on an automator workflow that would import text files to excel and chart them, but when I tried to name the worksheet–set name of newWorksheet to (name of inFile)–I was getting all kinds of errors. Now I am simply trying to get finder to give me the name of the selected file. Here is the script I am using:


tell application "Finder"
	set x to selection
	get x
	get info for x
end tell

And the event log:


tell application "Finder"
	get selection
		{document file "NanomaterialsSeminarLabTour.doc" of folder "Documents" of folder "willo" of folder "Users" of startup disk}
	info for {document file "NanomaterialsSeminarLabTour.doc" of folder "Documents" of folder "willo" of folder "Users" of startup disk}
		"Finder got an error: File document file NanomaterialsSeminarLabTour.doc wasn't found."

When I ask finder to get name of x (instead of get info for x), I get the following event log:


tell application "Finder"
	get selection
		{document file "NanomaterialsSeminarLabTour.doc" of folder "Documents" of folder "willo" of folder "Users" of startup disk}
		"Can't get name of {document file \"NanomaterialsSeminarLabTour.doc\" of folder \"Documents\" of folder \"willo\" of folder \"Users\" of startup disk of application \"Finder\"}."

Am I fundamentally misunderstanding how to query and set the properties of an object? If not, could anyone lend me some insight as to what might be going on?

Thank you,
will

Model: 15" Powerbook
AppleScript: 1.10
Browser: Safari 412.5
Operating System: Mac OS X (10.4)

tell application "Finder"
	set x to selection as alias
	get x
	get info for x
	set theName to name of x
	set theCreationDate to creation date of x
	--and so on, etc
	--Don't forget to coerce as necessary!
end tell

-N

Thank you, that works. I don’t pretend to understand why, but if it works, I won’t argue.

Keyzer.

There’s an explanation about why coercing the Finder selection to alias works, and when you can do it, here. ‘info for’ is a StandardAdditions command that requires an alias or file specification parameter. The two ‘get’ lines in the script above are superfluous as nothing’s done with their results.