Re: Finding Filenames that contain a certain string
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