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: Thu, 19 Jul 2007 21:16:14 -0400
Since this is the AppleScript users list I think it's perfectly reasonable
to recommend AppleScript solutions. Not everyone has learned shell scripting
or uses "do shell script" or wants to or needs to. I think appleScript
novices may be getting misleading information if every simple scripting
question is answered with only shell scripting solutions.
Ed: That's twice now you've said something about there being too many
shellscript replies on here; I think you are both succumbing to
selective attention and overreacting.
There are certainly solutions that are better done with nothing but
AppleScript - heck, I'm probably one of the more "egregious"
shellscripters on here, and I just replied an hour or so ago on the
other thread (about renaming files to remove a level of subdirectory)
that Finder scripting was the way to go. If you're keeping score at
home, that's 50% pure AS, 50% "do shell script" in one day of my
contributions.
But, I also don't think that "do shell script" should be avoided as if
it were somehow impure. There are occasions where it is appropriate,
where the equivalent Applescript-only solution is more cumbersome or
less efficient or both. I feel that this is such a case, although
obviously the "cumbersome" part is a subjective opinion. (At least, I
think it's obviously subjective; you seem to be stating as a fact that
the AS-only solution is "better". I'm curious about your definition.)
In the particular problem under discussion, I feel (see? subjective)
that a regex-based solution - where you can say "does this string
match the pattern l3105[a-z]" - is cleaner then a loop-based solution
where you have to say "does this string match l3105a? What about
l3105b? OK, what about l3105c?" etc. And there seem to be others on
the list who agree.
The use of regexes (or other pattern matching) still doesn't mean you
have to use the shell, of course. Satimage's regex capabilities will
do the trick. But unlike "do shell script", Satimage doesn't ship
with the OS (does that make it less pure/"vanilla" in your eyes?).
Also, as I said, if all you need is a simpler test - "does the
filename start with l3105" - then AS's built-in string comparison
operators will do the job lickety-split
--
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