Skip to content

@echoz /gist:1426818

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Applescript to add a prefix to all phone numbers with checking to see if they are singaporean numbers (8 digits)
tell application "Address Book"
set prefix to "+65"
repeat with p in (get people)
repeat with n in (get p's phones)
set num to ReplaceText(n's value, " ", "") of me
if (count num) is 8 then
set n's value to prefix & num
end if
end repeat
save p
end repeat
end tell
on ReplaceText(theString, fString, rString)
set current_Delimiters to text item delimiters of AppleScript
set AppleScript's text item delimiters to fString
set sList to every text item of theString
set AppleScript's text item delimiters to rString
set newString to sList as string
set AppleScript's text item delimiters to current_Delimiters
return newString
end ReplaceText

added replacement of text function from somewhere to remove spaces in the phone number field.


Works as advertised. Thanks! Only suggestion would be to log whose card has been changed, so the user can keep track of it in case anything goes wrong.


as they say... always backup before you make changes. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.