Re: Sort folder list descending
Re: Sort folder list descending
- Subject: Re: Sort folder list descending
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 25 Mar 2010 23:11:44 -0400
In case anyone was about to try this on Finder items, please don't.
While the handlers work well in general, it seems that the
tell aScript to open(anItem)
completely ignores aScript's "open" handler in favor of the open
handler defined on the item! So the script will tell the Finder to
open all the items whose name you're trying to retrieve. Hello,
windows!
You can work around this by using a custom handler name for the
purpose rather than the open handler, although that's not as nicely
general on the map() side.
On Thu, Mar 25, 2010 at 6:04 PM, Mark J. Reed <email@hidden> wrote:
> In the category of "how to do things that you really shouldn't be
> doing with AppleScript", I like these handlers:
>
> on map(aScript, aList)
> set resultList to {}
> repeat with anItem in aList
> tell aScript to open(anItem)
> set end of resultList to the result
> end repeat
> return resultList
> end
>
> on pluck(propName, aList)
> set plucker to (run script "script" & return & "on open(foo)" & return & "ret
> urn(get " & propName & " of foo)" & return & "end" & return & "end")
> return map(plucker, aList)
> end pluck
>
> which would let you do this:
>
> set myNames to pluck("name", myItems)
>
>
>
> On Thu, Mar 25, 2010 at 5:28 PM, Alex Zavatone <email@hidden> wrote:
>>
>> On Mar 25, 2010, at 4:20 PM, Luther Fuller wrote:
>>
>> On Mar 25, 2010, at 4:10 PM, Alex Zavatone wrote:
>>
>> Ok, it looks like this is most of the way there. Do you have a good way to
>> get the text name of the folder out of the resulting list while keeping the
>> sort order?
>> How do I simply get the folder name of these folders as
>> On Mar 25, 2010, at 3:33 PM, Luther Fuller wrote:
>>
>> get sort (get folders of sourceFolder) by modification date
>> set folderList to (reverse of the result) as alias list
>>
>> Perhaps this does what you are looking for ...
>> set sourceFolder to alias "OS_X:Library:Frameworks" -- for example
>> tell application "Finder"
>> get sort (get folders of sourceFolder) by modification date
>> set folderList to (reverse of the result) as alias list
>> --
>> repeat with i from 1 to (count items of folderList)
>> (name of item i of folderList) as text
>> display dialog the result
>> end repeat
>> end tell
>> beep
>> Or not?
>>
>> Yep. That does. I saw that I could get the name of an individual item of
>> the list but for some reason you can not get the name of every item or each
>> item in the list. I was hoping there was one of those elegant AppleScript
>> one liners that lets you do a loop in one line.
>> Sometimes, it's pretty impossible to know when AppleScript will let you do
>> do something and when it won't.
>> Thanks Luther. You saved me serious pain here.
>> Cheers,
>> - Alex
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Mark J. Reed <email@hidden>
>
--
Mark J. Reed <email@hidden>
_______________________________________________
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