AppleScript: Search&Replace im Adressbuch

Vielleicht auch praktisch, das Ding durchsucht Adressen im Adressbuch nach Zeichen (im Code werden Zeilenumbrüche ersetzt) in den Adress-Feldern und löscht diese. :-?
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

--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

This entry was posted in Address Book and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


× 3 = six

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...