• 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: Sorting file lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting file lists


  • Subject: Re: Sorting file lists
  • From: Nigel Garvey <email@hidden>
  • Date: Mon, 20 Oct 2003 10:33:38 +0100

"Dr Digby L. James" wrote on Sun, 19 Oct 2003 18:22:13 +0100:

>I'm creating a list of files using the list folder which I'm then
>using to import files into Quark. Is there a simple way to list the
>files according to date and time? The order I presently get is
>alphabetical, so file-2.tiff comes after file-19.tiff. Or do I need
>to first get the script to rename all of the files file-002.tiff, etc
>so that the alphabetical order is the correct order?

The script below arranges the names of a folder's files according to the
files' creation dates and is quite fast. In the summer, Rick Bargerhuff
and I put together a script for sorting names alphanumerically rather
than just alphabetically. This is only half as fast and is quite a bit
longer, but sorts on names rather than dates. If you'd like it posted,
let me know.

(* Based on QuickSort by Arthur J Knapp *)
-- This version arranges a second list using the sort moves for the
first
on parallelQuickSort(sortList, otherList, l, r) -- sorts in-place

local i, j, v

-- Much thanks to both Serge Belleudy-d'Espinose and Victor Yee
-- for the script-referencing techniques that they helped to
-- refine.
--
script o
property list1 : sortList
property list2 : otherList
end script

set i to l
set j to r
set v to o's list1's item ((l + r) div 2)

repeat while (j > i)

repeat while (o's list1's item i < v)
set i to i + 1
end repeat

repeat while (o's list1's item j > v)
set j to j - 1
end repeat

if (not i > j) then
tell o's list1's item i
set o's list1's item i to o's list1's item j
set o's list1's item j to it
end tell
tell o's list2's item i
set o's list2's item i to o's list2's item j
set o's list2's item j to it
end tell

set {i, j} to {i + 1, j - 1}
end if
end repeat

if (l < j) then parallelQuickSort(o's list1, o's list2, l, j)
if (r > i) then parallelQuickSort(o's list1, o's list2, i, r)

end parallelQuickSort


set theFolder to (choose folder)
tell application "Finder"
set {creationDates, fileNames} to {creation date, name} of
theFolder's files
end tell

count creationDates
if result > 0 then parallelQuickSort(creationDates, fileNames, 1,
result)
--> Both creationDates and fileNames are sorted by creation date
fileNames

NG
_______________________________________________
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.

  • Follow-Ups:
    • Re: Sorting file lists
      • From: "Dr Digby L. James" <email@hidden>
  • Prev by Date: screensaver with password and different to default
  • Next by Date: Re: new style spec for XPress 4.XX
  • Previous by thread: Re: Sorting file lists
  • Next by thread: Re: Sorting file lists
  • Index(es):
    • Date
    • Thread