Getting file info

I have the following script snippet to get file info data:
tell application “System Events”
set info_ to (info for (someItem) without size)
set folder_ to (folder) of info_
end tell

someItem is an alias.

I get the error message: Can’t get folder of … followed by a list of what’s in info_. The code works for most data (name, visible, extension hidden, creation date), not with others (folder, name extension). It looks from the error message that info contains valid data. Can someone explain what’s going on and how I can get to the ones that don’t work.

Thanks

Welcome to the forum.

The info-for command is part of Standard Additions and should not be included in a System Events tell block. So, delete those lines and your script works as expected. Just by way of example:

set someItem to (choose file) -- returns alias

set info_ to info for someItem without size

set folder_ to folder of info_ -- returns true or false 

BTW, the AppleScript dictionary for Standard Additions contains the following:

So, if a property will supply the desired information, this would be the preferred approach. To see what those properties are, simply run the following script in Script Editor and look in the Result window:

set aFile to choose file

tell application "System Events"
	properties of aFile
end tell

As I see, you want to get the container folder of the chosen item. You can get this folder directly, without getting all item’s properties:


tell application "System Events" to set folder_to to container of someItem

Thanks very much for the help. My script is now merrily marching along.