Skip to content

Instantly share code, notes, and snippets.

@joubin
Last active July 15, 2017 03:31
Show Gist options
  • Save joubin/12f6fd0a8e6f1d28d948a85be25c20eb to your computer and use it in GitHub Desktop.
Save joubin/12f6fd0a8e6f1d28d948a85be25c20eb to your computer and use it in GitHub Desktop.
If you are like me, you've carried over your contacts for many years. Sometimes from the years where you didn't have any contacts in different area codes. Over the years, I've updated the contacts without area codes manually. Recently, I left the country and ran into a problem calling US numbers with a European sim in my phone. The cooperate, no…
tell application "Contacts"
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" and theNum does not start with "0")) then
set value of eachNumber to "+1" & theNum
else if (theNum starts with "1") then
set value of eachNumber to "+" & theNum
end if
end repeat
end repeat
save
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment