• 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: Christopher Stone <email@hidden>
  • Date: Fri, 10 Feb 2012 04:50:17 -0600

Hey Shane,

On Feb 09, 2012, at 16:15, Shane Stanley wrote:
That's much better, but you left out the "as alias" after set contents of i to (folderAlias & contents of i).

Hmm.  You're right.  I think I did that intentionally to allow choice in how to process the string, but I forgot to rename the variables.  (Not sure; I've slept since then.)

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 ':' '/'")

Sure enough.  Well, we might as well use the shell a bit more:

------------------------------------------------------------------------------------------------
on listFolderByModDate(folderAlias, returnAliasList)
set posixFolder to POSIX path of folderAlias
set posixFolderQuoted to quoted form of posixFolder
set hfsPathList to (do shell script "ls -tr " & posixFolderQuoted & " | sed \"s|:|/|g;s|^|" & (folderAlias as string) & "|\"")
if returnAliasList = true then
set aliasList to (paragraphs of hfsPathList)
repeat with i in aliasList
set theItem to contents of i
set (contents of i) to (alias theItem)
end repeat
return aliasList
else
return hfsPathList
end if
end listFolderByModDate
------------------------------------------------------------------------------------------------
try

tell application "Finder"

set folderAlias to target of front window as alias
end tell


set sortedItemList to listFolderByModDate(folderAlias, true)


on error eMsg number eNum
set {c, s} to {return, "------------------------------------------"}
set e to s & c & "Error: " & eMsg & c & s & c & "Error_Num: " & eNum & c & s
beep
display dialog e
end try
------------------------------------------------------------------------------------------------

This runs in ~ 0.6 seconds on a 1600 item folder on my machine when converting to aliases.

When returning HFS paths it runs in ~ 0.13 seconds on the same folder.

--
Best Regards,
Chris

 _______________________________________________
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: Shane Stanley <email@hidden>
    • Re: Sort error in Leopard
      • From: KOENIG Yvan <email@hidden>
References: 
 >Re: Sort error in Leopard (From: Nigel Garvey <email@hidden>)
 >Re: Sort error in Leopard (From: Christopher Stone <email@hidden>)
 >Re: Sort error in Leopard (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Sort error in Leopard
  • 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