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: Nigel Garvey <email@hidden>
- Date: Tue, 20 Aug 2002 01:07:43 +0100
Nigel Garvey wrote on Sun, 18 Aug 2002 00:31:03 +0100:
>
Bill Briggs wrote on Sat, 17 Aug 2002 14:56:39 -0300:
[re discussion about getting an alphabetically sorted list of a folder's
contents, wherein I suggested the Finder's 'sort' command]
>
> It may be relevant to the original poster that this sorting
>
>operation in the finder coerces all of the aliases into Finder's file
>
>references. That may be acceptable, but it may not be good, depending
>
>on how he wants to process the list.
>
>
>
> Unfortunately, a one-shot conversion using "as alias list" won't
>
>coerce the lot back. If he wants an alias list, he'll have got to
>
>loop through to coerce each one individually.
>
Another approach, if aliases are required, is to remember that the
>
contents of a folder *are* normally returned in alphabetical order. The
>
order's only spoilt when something happens within the folder. (Hence the
>
original question.) On my machines (Mac OS 9.2.1 and 8.6) it's possible
>
to force a reset by opening and shutting the folder.
Following some off-list discussion with Andy Wylie, I've done more tests
which suggest that the alphabetical order is only disturbed if the
folder's open when an item's added to it (or if a subfolder's opened). If
the folder's not open, or if it's subsequently closed, listing its
contents returns a fully sorted list. With that in mind, I'd revise the
script I posted to shut and then open the folder - but only if it's open
already:
set source1 to (choose folder) as string
tell application "Finder"
tell folder source1
if its container window exists then
close
open
end if
try
set theList to (its every file whose file type is "TEXT") as
alias list
on error
set theList to (its first file whose file type is "TEXT") as
alias as list
end try
end tell
end tell
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.