Re: RegEx Commands
Re: RegEx Commands
- Subject: Re: RegEx Commands
- From: Simon Topliss <email@hidden>
- Date: Tue, 07 Aug 2001 12:55:19 +0100
Thanks to everyone who helped on this one.
I had a version of JR's snippet using TID's working beautifully. However, I
ran into big problems when an Illustrator file contained embedded images
instead of a path to a linked image.
>
-- begin script
>
set someString to "ignore this
>
ignore this
>
ignore this
>
%AI5_BeginRaster
>
(Mac HD:Desktop Folder:Bear.tif) 0 XG
>
ignore this
>
ignore this"
>
>
set saveDelims to AppleScript's text item delimiters
>
set AppleScript's text item delimiters to {"%AI5_BeginRaster" & return &
>
"("}
>
set itemList to the text items of someString
>
set AppleScript's text item delimiters to saveDelims
>
>
set someString to (item 2 of itemList)
>
>
set saveDelims to AppleScript's text item delimiters
>
set AppleScript's text item delimiters to {")"}
>
set itemList to the text items of someString
>
set AppleScript's text item delimiters to saveDelims
>
>
log item 1 of itemList
>
-- end script
One file had 10 embedded images so the resulting text items were each 296K
causing a stack overflow.
So, I really have to thank Scott for his help with the syntax for RegEx. I
would have been for days trying to work that out!!
>
REMatch theString pattern "%AI5_BeginRaster\\r\\(([^)]*)\\)
>
separator "" using "\\1"
Because RegEx returns a string of matches, memory was less of a problem.
If anyone would like a copy of a script that scans a given folder for every
Adobe Illustrator file, then for each AI file it finds creates an Excel
entry showing whether the file has any linked images and whether the linked
images are present in the folder, let me know and I'll send you a copy
off-list. There's not much in the way of error checking, but it could easily
be improved and made into a droplet.
Thanks,
Simon