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: "Mark J. Reed" <email@hidden>
- Date: Fri, 20 Jul 2007 15:45:50 -0400
On 7/20/07, Stockly, Ed <email@hidden> wrote:
(Of course, all this goes way beyond the scope of what the original poster
was asking for)
I don't think it does. The OP wanted to find all files within a given
folder whose names consisted of a given prefix, followed by any
lowercase letter, followed by anything else.
Finding all files within a given folder whose names include a given
prefix is easy in plan AppleScript + the Finder (which darn well
better be there on any Mac). It's when you hit the "followed by any
lowercase letter" requirement that we seem to diverge.
I feel that a regex solution, where I can use the range notation
[a-z], is both simpler to construct and easier to read than a solution
that requires explicitly enumerating (either as a literal or via
construction) a 26-element list containing all the lowercase letters.
That would seem to be exactly the opposite of the AppleScript
philosophy; I mean, in English, I can just say "the lowercase letters"
and you know what I mean. I don't have to say "Lowercase A or B or C
or D or E or...".
In an ideal world, the Finder would support regular expression
matching on filenames directly, and would have done so long before OS
X. Regular expressions, after all, are not inherently a shell
concept, or even a UNIX one. But since the Finder doesn't have that
capability, something more is required.
Satimage lets you do regex comparisons on strings. That's perfect, if
you have it, but I'm reluctant to suggest solutions that require the
installation of something that didn't come standard with the system.
(Or even something that did come standard but is not installed by
default, like, say, X11.)
The "do shell script" command, in contrast, does come standard with
the system. It's not pure AS (it's in a scripting addition), but it
requires no additional setup work on the part of the AS programmer to
gain access to it. Now, the shell, as it happens, does regular
expression matching. So using it seemed to be an obvious solution to
the problem.
I imagine we'll just have to agree to disagree here. But I am curious
about your other assertion that "every simple question gets a do shell
script response". I don't share that impression, but it would seem to
be an objectively measurable question given access to the list
archives...
--
Mark J. Reed <email@hidden>
_______________________________________________
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