On March 20, all telephones in Costa Rica will be changing from seven digits to eight digits. This means that all cell phones will now be preceded by the number eight whereas every other line will be preceded by the number two.

Changing to the new format is going to be a major pain in the ass for everyone, especially those that cannot synchronize their phone numbers with their computer. If you are one of these unlucky bastards, then this post is not for you.

As requested by my sister, I had the displeasure of working with AppleScript one more time to create a script that would change the phone numbers from address book to the new format. The script checks every number in your address book and only changes those numbers that (after removing empty characters, and other quirks) are of length seven. I have tested the script with all the addresses on my address book and so far it it has been able to replace every one of them correctly. In theory, the script will only modify numbers from Costa Rica. This does not mean that the script is perfect, so use at your own risk.

Remember to always always always always back up your address book before running this script. if you need help backing up, please check the following link: http://docs.info.apple.com/article.html?path=AddressBook/4.0/en/disc.html

Download the script from the following location:

http://tinyurl.com/y8qd66t

How to use it

Once you have downloaded the file, carry out the following steps:

  1. Open the script that you downloaded by double clicking on it (an application called script editor will the file for you)
  2. Your address book should automatically open
  3. Back up all of your information
  4. Highlight all of the contacts that you want to modify (you can quickly do this by going to the edit menu and choosing select all)
  5. Switch back to the script editor application and hit the big Green Run button:
  6. ZZ090BABEA.jpg
  7. Follow the directions

The operation is dependent on the number of contacts that you have. I have about 315 cards and the process took about 10 seconds.

7 Responses to “AppleScript to change address book phone numbers to new format in Costa Rica”

  1. Jose Says:

    You need to modify the condition for mobile phones to:

    if (length of trimmedPhone = 7) then
    if phoneLabel = “mobile” or trimmedPhone begins with “8″ or trimmedPhone begins with “3″ or trimmedPhone begins with “9″ then

    Other than that, it worked flawlessly. Great Work!! Thanks!! :-)

  2. christian Says:

    Thanks a lot! I have changed the script and uploaded the new version.

    Very glad to hear that someone else found it useful – it makes all that time debugging with “display dialogs” whilst screaming all worthwhile. :)

  3. Jeannyna Says:

    Great job!!!! Worked perfectly and by the way saved my day!

    I owe you the beer! ;)

    Thanks!!!!!

  4. Donald G Says:

    Hi there,

    Do you know where I can find an AppleScript to change all my Address Book phone number entries with a “809″ area code to a “1-809″ area code so that I do not have to input the “1″ EVERY time I have to dial those 809 numbers — which is many times a day?

    Thanks so much!

    - Donald

  5. cameron Says:

    Hi,
    Please re-up, the link expired

    thanks

  6. grumpytico Says:

    Here you go, sorry for the dead link:

    http://tinyurl.com/y8qd66t

  7. August Young Says:

    Is there a way you can add a +1 to the phone numbers?
    When I import my address book into skype it will only work with numbers with country codes.. .so annoying
    Thanks!

Leave a Reply