Created
September 23, 2012 15:01
-
-
Save mzcu/3771916 to your computer and use it in GitHub Desktop.
Add country code to OS X Address book entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
AddCountryCode.scpt | |
===================== | |
Customization of Andreas Amann's script posted on https://discussions.apple.com/message/9169756#9169756 | |
Description | |
------------ | |
Adds RS country code prefix (+381) to all phonebook entries with leading zero (RS local number format): 063123456 -> +38163123456 | |
Back up your Address book before running this script, your mileage may vary!!! | |
Usage | |
------ | |
Paste to AppleScript Editor and click "Run". | |
*) | |
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 "381" and theNum starts with "0") then | |
-- log "+381" & (get text 2 thru (length of theNum) of theNum) | |
set value of eachNumber to "+381" & (get text 2 thru (length of theNum) of 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
@bluestarstudios Great update! I made a couple small changes to add a little more information to logging and allow for dry runs: https://gist.github.com/nquinlan/7d4b5716eb0644dac0af3b97dfc7cc54