Re: getting a file list in sorted order
Re: getting a file list in sorted order
- Subject: Re: getting a file list in sorted order
- From: Steven Angier <email@hidden>
- Date: Sun, 18 Aug 2002 14:25:14 +1000
On 17/8/02 9:38 PM, "Jim Brandt" <email@hidden> wrote:
>
I've got a script that for the most part works well for me. The one
>
thing I don't like about it has to do with the order of a list that
>
is generated by the command:
>
>
set theList to every item of alias source1 whose file type is "TEXT"
>
>
This list of aliases is not sorted alphabetically as the file list
>
would be shown in a list view. I'm guessing the list is built
>
according to the order the files (at least the ones selected) were
>
put into the directory in the first place.
>
>
The question: Is there a way to tell Applescript to build the list in
>
a sorted order? If not, is there a simple way to sort a list of
>
aliases?
>
>
Jim Brandt
>
_______________________________________________
>
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.
If you want my advice, here it is:
1. Use the Macscript.com Library as it has several functions for listing
files and folders, including 2 that filter in only the supplied file and/or
creator types:
FilterFileList()
FilterFiles()
GetFiles()
GetFilesFromList()
GetFolders()
GetFoldersFromList()
ListFolder()
So, instead of:
set theList to every item of alias source1 whose file type is "TEXT"
You could type:
set theList to FilterFiles(source1,"TEXT",{})
And you would get a list of all files of type "TEXT" in the given folder,
sorted alphabetically.
2. If you must (or want to) do things yourself, AVOID USING THE FINDER
WHENEVER POSSIBLE. The Finder still craps out from time to time when sorting
or when getting long or recursive directory listings (stack overflows).
The "list folder" command (upon which all Macscript.com Library file listing
functions is based) returns file names sorted alphabetically. It returns a
list of names which you have to concatenate with the parent folder path, and
test the type and/or creator.
This method maybe slower than using the Finder, but at least you get the
right answer.
A 30-day demo of the Library is available from our site
<
http://www.macscript.com>.
Steven Angier
Macscript.com
_______________________________________________
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.