Re: alias is folder?
Re: alias is folder?
- Subject: Re: alias is folder?
- From: Christopher Nebel <email@hidden>
- Date: Sun, 27 Apr 2003 23:13:23 -0400
On Sunday, April 27, 2003, at 10:34 PM, Paul Berkowitz wrote:
On 4/27/03 6:58 PM, "Christopher Nebel" <email@hidden> wrote:
On Sunday, April 27, 2003, at 10:35 AM, matt neuburg wrote:
On Sun, 27 Apr 2003 01:58:34 +0100, John Delacour <email@hidden> said:
tell app "Finder" to kind of (path to "cusr") is "Folder"
Actually,
kind of myAlias is "Folder"
works. The clue I needed is that there's a "kind" property. Thx - m.
Of course, it won't work unless you run in English. For example, in
French, the kind of myAlias is "Dossier". A more reliable approach
is this:
tell application "Finder"
get class of item myAlias --> folder
end tell
Does 'item myAlias' always coerce the alias to a file path? To be
safe aren't we back to my version JD found too verbose?
tell application "Finder"
get class of item (myAlias as Unicode text) --> folder
end tell
"item myAlias" doesn't coerce anything -- it resolves the alias, and
then returns a Finder object specifier that points to that file system
object. Coercing the alias to a path by hand would add nothing.
Some of the classes of files are quite peculiar (the most unlikely
things seem to be 'document files'). That's why my original script
here just asked for;
tell application "Finder"
exists folder (myAlias as Unicode text)
end tell
because the equivalent for 'file'
exists file (myAlias as Unicode text)
works OK, whereas trying to get the class of an item to see if it's a
file
does not have a satisfactory method, as far as I can see (yet). There
seem
to be various type of classes which come up for various kinds of file.
'file' (in the Finder) seems to be some kind of superclass, like
'item',
which do not generally appear as the result when you ask for the class
of an
item.
Ah, an interesting point. My suggestion works fairly well for folders,
since there are only two concrete "container" classes. (Well, only two
that you're going to see.) "File", on the other hand, has six
subclasses. This gets into matt's follow-up question about "is a kind
of" queries.
On the other hand, the "get kind of" technique works even worse for
files, since the kind string could literally be anything. You could
always use "info for" and check the "folder" attribute, I suppose.
--Chris Nebel
Apple Development Tools
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.