Re: Replace characters in filename
Re: Replace characters in filename
- Subject: Re: Replace characters in filename
- From: Graff <email@hidden>
- Date: Sat, 12 Jun 2004 19:36:40 -0400
On Jun 12, 2004, at 6:31 PM, Christopher Stone wrote:
At 16:51 -0400 06/12/2004, Graff wrought:
How would I find certain characters (any of a list of 13) in a
filename and replace them with one common character?
...
property disallowedCharacters : "1234567890ABCD"
property replacementCharacter : "!"
I thought I'd throw in a plug for the Satimage osax's regular
expressions.
set someFileName to "aGraphicsFile001A.jpg"
set newFileName to change "[0-9ABCD]" into "" in someFileName with
regexp and case sensitive
--> aGraphicsFile.jpg
Yeah, the Satimage OSAX is nice. I never use it because I try to keep
all my scripts to plain-vanilla AppleScript for portability.
You could of course use the shell to do the same:
set someFileName to quoted form of "aGraphicsFile001A.jpg"
set newFileName to do shell script "echo " & someFileName & " | sed
s/'[0-9ABDC]'/''/g"
- Ken
_______________________________________________
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.