Re: order of files in Finder vs. file index number
Re: order of files in Finder vs. file index number
- Subject: Re: order of files in Finder vs. file index number
- From: Christopher Nebel <email@hidden>
- Date: Wed, 26 Mar 2008 22:11:20 -0700
On Mar 26, 2008, at 2:21 PM, scriptcode wrote:
Is there a way to get AppleScript to manipulate files in a folder in
the
order they appear in the Finder rather than in the order of their
index
number?
I'm wanting to manipulate a large number of files using a repeat
loop, but
I get unwanted results because the order of display in the finder
isn't
the same as that seen by AppleScript references to the "first item" or
"item 2" etc.
For example, telling AppleScript to:
set listFiles to name of every item of folder sourceFolder
to these items:
031403c1_086 2
031403c1_086 100
(as displayed in Finder)
gives this:
{"031403c1_086 100", "031403c1_086 2"}
"every item" (or every folder, or whatever) of Finder is not
guaranteed to return the items in any particular order. The fact that
it even resembles alphabetical order is a function of the disk format,
HFS+ in this case. (Other formats, such as NFS, use different
ordering.) If you want them sorted the way Finder does, use Finder's
"sort" command. To sort your own data that way (that is, a bunch of
strings, not necessarily Finder items), use a "considering numeric
strings" block.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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