Skip to content

Instantly share code, notes, and snippets.

@noestreich
Last active August 21, 2018 13:21
Show Gist options
  • Save noestreich/486e7a5e3547878ac998195135380878 to your computer and use it in GitHub Desktop.
Save noestreich/486e7a5e3547878ac998195135380878 to your computer and use it in GitHub Desktop.
AppleScript ergänzt Rufnummern die mit 0 starten mit Ländervorwahl +49
set vorwahl to "+49"
tell application "Contacts"
repeat with aPerson in people
set thePhones to phones of aPerson
if thePhones is not {} then
set errorList to {}
repeat with aPhoneNumber in thePhones
set theNumber to value of aPhoneNumber
if (characters 1 thru 1 of theNumber) as string is "0" then
if (characters 1 thru 2 of theNumber) as string is not "00" then
try
set StringLength to count of characters in theNumber
set newNumber to vorwahl & (characters 2 thru StringLength of theNumber)
display dialog theNumber & " to " & newNumber
set value of aPhoneNumber to newNumber
on error
copy name of aPerson to end of errorList
end try
end if
end if
end repeat
if errorList is not {} then
display dialog "Couldn't change: " & items of errorList
end if
end if
end repeat
save
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment