I am new to this forum and my question is probably of type
My handler gets a list of aliases and checks the list for aliases pointing to folders in the file system.
Until now I have used the following code pattern to accomplish this:
set aliasList to { . }
repeat with itemAlias in aliasList
if folder of (info for itemAlias without size) then
.
end if
end repeat
This works fine but the Standard Additions command “info for.” has been deprecated some time ago in favor of System Events command “properties of.”.
My problem: How can a script detect whether an alias points to a folder or not ” without using “info for.” and without using 3rd-party Scripting Additions? I was unable to find a corresponding property neither in System Events nor elsewhere.
use the Finder or System Events and a string path list (or an alias - text coercion)
set aliasList to { . }
repeat with itemAlias in aliasList
tell application "System Events"
if class of item (itemAlias as text) is folder then
-- do something
end if
end tell
end repeat
I have included your solution into my scripts and it works fine. It even distinguishes file packages from folders. Nice!
On a related note: is it just me, or is this just another area where AppleScript should provide a less clumsy, more elegant way to accomplish something?
At first all (meta-)information about the target file (except its path) is thrown away (“itemAlias as text”). And immediately after that the same information is re-collected again (“item (.)”).
the Finder, System Events and info for gather all their information from the Cocoa Class NSFileManager or its Carbon counterpart.
in System Events and Finder the keyword item coerces the string path into a generic file/folder specifier, which contains all metadata.
The AppleScript class alias doesn’t know anything about the metadata, without Finder or System Events only the info for scripting addition adds a way to access the file information.