• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sort error in Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sort error in Leopard


  • Subject: Re: Sort error in Leopard
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 10 Feb 2012 09:15:33 +1100

On 09/02/2012, at 12:46 PM, Christopher Stone wrote:

Using the Finder to do the sort is rather grossly slow - 3 full seconds to sort 55 items on my i7 MacBook Pro with Lion.

By contrast this will run in ~ 0.05 seconds on the same folder:

on listFolderByModDate(folderAlias)
set posixFolder to POSIX path of folderAlias
set posixFolderQuoted to quoted form of posixFolder
set itemList to (do shell script "ls -tr " & posixFolderQuoted)
set itemList to paragraphs of itemList
return itemList
end listFolderByModDate
on makeAliasList(folderAlias, fileNameList)
set folderAlias to folderAlias as text
repeat with i in fileNameList
set contents of i to (folderAlias & contents of i)
end repeat
return fileNameList
end makeAliasList

set folderAlias to alias "Thor:Users:chris:Pictures:Downloads (New):"
set sortedFileNameList to listFolderByModDate(folderAlias)
makeAliasList(folderAlias, sortedFileNameList)

That's much better, but you left out the "as alias" after set contents of i to (folderAlias & contents of i) . And when you put it in, you get an error if any filename contains a slash. So I'd use:

set itemList to (do shell script "ls -tr " & posixFolderQuoted & " | tr ':' '/'")

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

  • Follow-Ups:
    • Re: Sort error in Leopard
      • From: Christopher Stone <email@hidden>
References: 
 >Re: Sort error in Leopard (From: Nigel Garvey <email@hidden>)
 >Re: Sort error in Leopard (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Issue with process names
  • Next by Date: Re: Sort error in Leopard
  • Previous by thread: Re: Sort error in Leopard
  • Next by thread: Re: Sort error in Leopard
  • Index(es):
    • Date
    • Thread