Re: Select Finder items by Regular Expression
Re: Select Finder items by Regular Expression
- Subject: Re: Select Finder items by Regular Expression
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 24 Aug 2005 13:42:32 -0400
On 8/24/05, Michelle Steiner <email@hidden> wrote:
> you want to select all the items whose name end in ".jpg" and contain "Fun"?
>
> This can be done with vanilla Applescript.
The vanilla Finder, anyway. And sure, you don't often need the power
of full regular expressions when dealing with filenames. That's why
the UNIX shells (and Perl's "glob" function) use a relatively crippped
version of them based on traditional pre-regex wildcard patterns. I'm
sure the stuff Finder includes is probably similar in expressibility
to those . . . I'm guessing you can say things like "name begins with"
and "name ends with" as well as "name contains", right?. Most of the
time, in the context of filenames, that's all you need; regexes really
come into their own with larger swatches of text.
But every once in a while, even with filenames, you do need more
descriptive power. That's why ksh88 introduced (and bash adopted,
although you have to turn on an option) real regular-expression
quantifiers [?(....), *(...), +(...)] to complement the traditional
wildcard syntax. And why I have various perl scripts to complement my
shellscript arsenal.
So while I don't personally envision myself needing to do this sort of
thing from AppleScript, that's only because I come from a UNIX
background and therefore do most of my file-manipulative scripting
from the UNIX side. (The first, and so far only, time I tried to
script the Finder, it was to change the icon on something, and that
didn't work anyway; I had to resort to GUI scripting System Events.
Bleah.) I can easily see the utility of this sort of library, and it
should be a good way of introducing the Mac-backgrounded side of the
house to the power of regexes. Thanks, Daniel!
>
> tell application "Finder"
> files of entire contents of startup disk whose name contains
> "Fun" and name extension is "jpg"
> end tell
>
>
> --
> I am Dyslexic of Borg. Fusistance is retile. Your ass will be laminated.
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
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:
This email sent to email@hidden