Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Clean up mobile numbers in Address Book Apps
To cut a long story short, my old phone wasn't very good at filing numbers though it did sync with Address Book. When I upgraded to a Sony Ericsson T610 I needed to clean up the numbers a bit to make sure they were stored nicely on the phone so I wrote this little script.

All it does is go through and internationalise all my mobile numbers and make sure any numbers in the mobile format are labled as mobiles.

set mobileCode to display dialog 
 ("Enter the mobile prefix code for your country:") 
 default answer "e.g. 07 for the UK"
set mobileCode to text returned of mobileCode
set countryCode to display dialog 
 ("Enter the country prefix code for your country:") 
 default answer "e.g. +44 for the UK"
set countryCode to text returned of countryCode
set internationalMobile to (countryCode & (character 2 of mobileCode))
tell application "Address Book"
  activate
  set ID_List to (id of people)
  repeat with anID in ID_List
    try
      set phoneList to the phones of person id anID
      repeat with aPhone in phoneList
        set phoneNumber to the value of aPhone as string
        set the_chars to characters 1 thru 4 of phoneNumber as string
        if the_chars is equal to internationalMobile then
          set the label of aPhone to "mobile"
        end if
        set the_chars to characters 1 thru 2 of phoneNumber as string
        if the_chars is equal to mobileCode then
          set interNumber to (countryCode & characters 2 thru 
          (the length of phoneNumber) of phoneNumber)
          set the value of aPhone to interNumber
          set the label of aPhone to "mobile"
        end if
      end repeat
    end try
  end repeat
  save addressbook
end tell
Feel free to use and modify as you like, but use the script at your own risk. Be sure to use the Backup Database command in Address Book before you experiment!
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[9,749 views]  

Clean up mobile numbers in Address Book | 1 comments | Create New Account
Click here to return to the 'Clean up mobile numbers in Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Clean up mobile numbers in Address Book
Authored by: sybian on Jan 27, '06 03:49:25AM

wauw - finally something to get rid of the mess. it works fine in 10.4.4
is there a simple tweak to change thsi script and changes al the landline numbers (netherlands) to internationalised numbers as well? (and not change 'type of' number)
thanks!



[ Reply to This | # ]