Re: Finding and replacing multiple characters
Re: Finding and replacing multiple characters
- Subject: Re: Finding and replacing multiple characters
- From: Robert Poland <email@hidden>
- Date: Tue, 8 Jul 2003 18:13:43 -0600
I need a script that would edit the names of files and folders in a
chosen directory. The following characters / \ : * ? " < > needs to be
replaced by an underscore.
I found this script, wich works great but only allows to change a
single character into an underscore.
set replace_chars to {"/", "\\", ":", "*", "?", "\"", "<", ">"}
set search_string to "How now / brown : cow * where < are > you > going?"
repeat with find_char in replace_chars
set text item delimiters to find_char
set search_string to (text items of search_string)
set text item delimiters to "_"
set search_string to search_string as text
end repeat
search_string
--> "How now _ brown _ cow _ where _ are _ you _ going_"
Here's an interesting variation on the above.
set replace_chars to {"/", "\\", ":", "*", "?", "\"", "<", ">", {space}, "___"}
set search_string to "How now / brown : cow * where < are > you > going?"
repeat with find_char in replace_chars
set text item delimiters to find_char
set search_string to (text items of search_string)
set text item delimiters to "_"
set search_string to search_string as text
end repeat
search_string
--
Bob Poland - Englewood, CO
http://www.ibrb.org/
_______________________________________________
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.