Re: 'grep' question
Re: 'grep' question
- Subject: Re: 'grep' question
- From: Andrew Oliver <email@hidden>
- Date: Mon, 17 Feb 2003 18:13:55 -0800
On 2/17/03 6:44 AM, "julifos" <email@hidden> wrote:
>
Hi all!
>
>
I don't know absolutely anything about 'grep', but I'll need it sooner or
>
later. My first question is: any simple tutorial on grep usage?
There is no specific, built-in grep function in AppleScript. What you'll
find is that there's usually a more English-like method of doing the same
job (as if *anything* could be less English-like than grep... ;) )
However, for those times when grep really is needed, there are several third
party scripting additions (OSAXen) around that implement grep engines. Maybe
you could show an example of what you're trying to achieve and someone can
suggest a non-grep solution, or tell you which addition to use.
>
>
Second question, any quick way through osaxen or shell scripting to
>
accomplish this pseudo-code?:
>
>
every item of folder x whose name = number
Ahh.. The beauty of AppleScript:
(assuming you want all files that contain a specific digit):
set x to choose folder
tell application "Finder"
set myList to every item of folder x whose name contains "1"
end tell
If you want a file that matches a specific number, change 'contains' to
'is'.
If you want to check prefixes, replace 'contains' with 'starts with'.
To check suffixes, replace 'contains' with 'ends with'.
To check only files (i.e. not folders) that match the name check, replace
'every item' with 'every file'
As you can see, it's very flexible.
Andrew
:)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.