AppleScript: Search&Replace im Adressbuch
by hubi on 14/03/2010--script to remove certain characters/strings from an address
set toBeRemoved to {"
"}
tell application "Address Book"
set my_selections to selection
repeat with my_selection in my_selections
repeat with i from 1 to count of every address of my_selection
repeat with current_replace_string in toBeRemoved
set current_replace_string to current_replace_string as text
set street of address i of my_selection to my replace_chars((street of address i of my_selection), current_replace_string, "")
set city of address i of my_selection to my replace_chars((city of address i of my_selection), current_replace_string, "")
set zip of address i of my_selection to my replace_chars((zip of address i of my_selection), current_replace_string, "")
set country of address i of my_selection to my replace_chars((country of address i of my_selection), current_replace_string, "")
set state of address i of my_selection to my replace_chars((state of address i of my_selection), current_replace_string, "")
end repeat
end repeat
end repeat
save
end tell
to replace_chars(this_text, search_string, replacement_string)
if this_text contains the search_string then
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
end if
return this_text
end replace_chars
No comments yet.