• 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: order of files in Finder vs. file index number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >order of files in Finder vs. file index number (From: "scriptcode" <email@hidden>)

  • Prev by Date: Re: order of files in Finder vs. file index number
  • Next by Date: [ANN] Smile 3.3
  • Previous by thread: Re: order of files in Finder vs. file index number
  • Next by thread: [ANN] Smile 3.3
  • Index(es):
    • Date
    • Thread