Re: Invisible Unix "Icon" File
Re: Invisible Unix "Icon" File
- Subject: Re: Invisible Unix "Icon" File
- From: Axel Luttgens <email@hidden>
- Date: Tue, 16 Nov 2010 10:27:38 +0100
Le 15 nov. 2010 à 16:52, Luther Fuller a écrit :
> [...]
> I ought to be able to shorten the code above to ...
>
> set msgList to (reverse of (sort items of sourceFolder by modification date)) as alias list
>
> but the Finder seems not to understand alias list despite its dictionary.
Hello Luther,
That "as alias list" locution never has been a coercion operator; it just asks the Finder to return a list of AppleScript aliases instead of a list of references to Finder items when the Finder is going to *produce* such a list.
As a result, "as alias list" generally applies to reference forms, and is otherwise silently ignored in most cases:
tell application "Finder"
items of desktop as alias list
--> {"alias "Boot", alias "Boot:Users:luttgens:Desktop:testfile"}
{"a", "b"} as alias list
--> {"a", "b"}
end tell
Contrast the above with this one:
tell application "Finder"
items of desktop
--> {startup disk, document file "testfile" of desktop}
result as alias list
--> {startup disk, document file "testfile" of desktop}
end tell
Here, "as alias list" came too late: the Finder already had built a list (an AppleScript list) of references.
Back to your example, or more exactly an equivalent of it:
tell application "Finder"
reverse of (sort items of desktop by modification date) as alias list
--> {startup disk, document file "testfile" of desktop}
end tell
Here, the Finder needs to evaluate "items of desktop", so as to get a list of references to Finder items; that way, it may apply its "sort" command, then take the "reverse" property of the resulting list. Finally, "as alias list" is ignored.
For having "as alias list" to operate, one could slightly rewrite above command, yet without being more successful anyway:
tell application "Finder"
reverse of (sort (items of desktop as alias list) by modification date)
--> {startup disk, document file "testfile" of desktop}
end tell
In this case, "items of desktop as alias list" indeed returns a list of aliases; but for being able to sort that list by making use of its "sort" command, the Finder needs to coerce those aliases back to Finder objects... not really efficient, nor useful. ;-)
This raises the question to know what is going to happen with your list of aliases; since you already are in the Finder, couldn't it be the right tool to natively perform all or part of the intended operations?
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden