• 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: Finding Filenames that contain a certain string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding Filenames that contain a certain string


  • Subject: Re: Finding Filenames that contain a certain string
  • From: Matt Deatherage <email@hidden>
  • Date: Thu, 19 Jul 2007 19:20:44 -0500

On 7/19/07 at 6:03 PM, Mark J. Reed <email@hidden> wrote:

> It's that expressiveness thing again.  Having to list out all 26
> possible prefixes strikes me as clunky, to say the list.

Never "say the list" when you can build one, unless you have to do it
thousands of times:

set fileList to {}
repeat with asc from (ASCII number "a") to ASCII number "z"
    set fileList to fileList & ("l325010" & (ASCII character asc) as text)
end repeat

[...continue with Ed's routine]

This is every bit as readable to me as:

> "ls -1 " & strImageRef & "[a-z]*"

...and is traceable and debuggable in Script Editor or Script Debugger.

If there's a performance penalty for building a large list, keep the
code in comments, run it once, and paste the results directly into the
script.  I always prefer an AppleScript solution to a shell one unless
the AppleScript one is just too slow or impractical (I'll pick a shell
command over a non-Apple scripting addition most times so I don't have
to worry about installing things), and even if I were to use the "ls"
command for speed on a huge or remote folder, I'd want the AppleScript
version handy.

--Matt

--
Matt Deatherage                              <email@hidden>
GCSF, Incorporated                      <http://www.macjournals.com>

I learn something new every day, and most days I don't like it.


 _______________________________________________
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: 
 >Re: Finding Filenames that contain a certain string (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Applescript Help...
  • Next by Date: Re: Opening Filemaker 8 DB
  • Previous by thread: Re: Finding Filenames that contain a certain string
  • Next by thread: RE: Finding Filenames that contain a certain string
  • Index(es):
    • Date
    • Thread