• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Replace characters in filename
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Replace characters in filename
      • From: Christopher Stone <email@hidden>
References: 
 >Replace characters in filename (From: Rick Davis <email@hidden>)
 >Re: Replace characters in filename (From: Graff <email@hidden>)
 >Re: Replace characters in filename (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Saving SE dictionaries
  • Next by Date: Re: Replace characters in filename
  • Previous by thread: Re: Replace characters in filename
  • Next by thread: Re: Replace characters in filename
  • Index(es):
    • Date
    • Thread