¿Adding new laber/number to all of Address Book's contacts?

Discussion in 'Mac Programming' started by MarceFX, Oct 21, 2009.

  1. macrumors member

    Joined:
    Sep 23, 2006
    Location:
    Graná (Spain)
    #1
    Hi there!

    I need to add a new label and number to each of my contacts in Address Book. The number must be a copy of each number in each contact. As an example:

    - Original -
    Name: John Doe
    Mobile: 666666
    Work: 7777777

    - Target -

    Name: John Doe
    Mobile: 666666
    Work: 7777777
    New label: XXX666666X
    New Label: XXX777777X

    So far I've just gotten to the part where I add the "XXX" and the final "X" using this script:

    Code:
    tell application "Address Book"
       repeat with eachPerson in people
          repeat with eachNumber in phones of eachPerson
             set theNum to (get value of eachNumber)
             if (theNum does not start with "+" and theNum does not start with "1") then
                set value of eachNumber to "XXX" & theNum & "X"
             end if
          end repeat
       end repeat
       save addressbook
    end tell
    
    Now I'm stuck on how to create the new phone/label for each contact's phone.

    ¿Any help please?

    Thank you
     

Share This Page