Add +1 To All Contacts (USA)

I found an older AppleScript to add "+1" to all existing telephone number in Contacts (formerly Address Book"), however, it fails with the error "Syntax Error: Internal Table Overflow." when trying to compile the script. I am a novice with AppleScript, so am hoping someone can provide some guidance.


I did change "Address Book" to "Contacts", however, that made no difference. The original author of the code said he had moved to Japan, thus the 0 conditions in the code. I just want to add the +1 since I am in the United States and all my contacts are in the United States, rather than abroad. I currently have 384 contacts. I am using macOS X 12.1.


Thank you.


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" and theNum does not start with "0") then
set value of eachNumber to "+1" & theNum
end if
end repeat
end repeat
save
end tell

MacBook Pro 15″, macOS 12.1

Posted on Jan 26, 2022 9:54 AM

Reply
7 replies

Feb 16, 2022 12:45 PM in response to AppleFanBoy62

I think I found the answer, which is to remove the save command. That allows the AppleScript to compile. I read on a post and it said the need for "save" was depricated.


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" and theNum does not start with "0") thenset value of eachNumber to "+1" & theNum
end if
end repeat
end repeat
end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Add +1 To All Contacts (USA)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.