I need to change all the phone numbers with “Work Mobile” to plain “Mobile” in my Address Book. I am guessing there is a way to do this with Applescript, and so this will be my first project. Needless to say, I am a newbie. The reason I need to do this is due to the way Plaxo syncs my contacts with Outlook on my pc. Thanks in advance…
Rushing to work. But you can start with this to help in your project.
I SUGGEST YOU BACKUP YOUR ADDRESS BOOK FIRST BEFORE PLAYING WITH CHANGING LABELS.
if you do not you may find you have some undesired results that will be Very hard to change back.
i.e all Phone Labels getting changed.
This snippet works on the entry/s selected.
It will change the first Phone number to Mobile.
what you need to do is get it to select the “Work Mobile” regardless of its position.
tell application "Address Book"
set theentry to selection
repeat with i from 1 to number of items in theentry
set this_item2 to item i of theentry
set label of phone 1 of this_item2 to "Mobile"
save addressbook
end repeat
end tell
Hi,
I had this script lying around. I’d second Mark Hunte’s suggestion of backing up before doing something like this.
set theOld to "MYold" -- label to replace
set theNew to "MYnew" -- new label
tell application "Address Book"
--to mark time taken
set startTime to (current date)
-- get people whose phone labels contain the old term
set thePeople to (get every person whose label of phones contains theOld)
-- loop through these people
repeat with aPerson in thePeople
-- loop through phone entries with the old term
repeat with myPhone in (phones of aPerson whose label is equal to theOld)
-- set the label to the new label
set the label of myPhone to theNew
end repeat
end repeat
-- to refresh
save addressbook
-- to mark time taken
set takenTime to (current date) - startTime
-- display confirmation
display dialog "All \"" & theOld & "\" changed to \"" & theNew & "\"," & return & (count thePeople) & " records changed," & return & "in " & takenTime & " seconds." as string buttons {"OK"} default button 1
end tell
Best wishes
John M