Benches macOS

4

removing the country code prefix from all…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

upgrading my iphone (to os 3.0) added country codes to all of my contacts,

not noticing this i synced it with my mac, thus adding said preixes to the contacts on my mac as well.

is there a way (only applescript from what i understand) to remove the country code from all my contacts?

thanks!

4 replies

Sign in or join Beachball Help to reply.

  1. 0

    V.K.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    yes, it can be done with applescript but please give more details. what is the exact country code? is it always the same one or do you have several country codes there? please give an example of what a phone number looks now and how you want it to be.

    Message was edited by: V.K.

  2. 0

    nimrod401

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    well the country code is +972 and i would like it to be replaced by zero.

    for example:

    +972 54 1234567 -> 054 1234567

  3. 0

    V.K.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    paste the following into Script Editor

    <pre style="

    font-family: Monaco, 'Courier New', Courier, monospace;

    font-size: 10px;

    margin: 0px;

    padding: 5px;

    border: 1px solid #000000;

    width: 720px;

    color: #000000;

    background-color: #ADD8E6;

    overflow: auto;"

    title="this text can be pasted into the Script Editor">

    tell application "Address Book"

    set mlist to selection

    repeat with per in mlist

    set NP to number of phones of per

    repeat with i from 1 to NP

    set curphone to value of (phone i of per) as text

    if text 1 thru 4 of curphone is "+972" then

    set value of phone i of per to "0" & text 5 thru -1 of curphone

    end if

    end repeat

    end repeat

    save

    end tell</pre>

    select all the contacts you want to be affected in Address Book (you can select them all) and press "run" in script editor.

  4. 0

    nimrod401

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    WOW!

    i should really learn to apple script 🙂

    thanks!