Imported from the Apple Support Forums via the Wayback Machine 🔗
Hi folks, I was trying to write a script to remove + signs from any phone numbers that contain them.
the following script throws up an error for some reason.
<pre style=" font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; margin: 0px; padding: 5px; border: 1px solid #000000; width: 720px; color: #000000; background-color: #ADD8E6; overflow: auto;" title="this text can be pasted into the Script Editor"> tell application "Address Book" repeat with Acontact in people repeat with APhone in phones of Acontact set current_phone to value of APhone
set value of APhone to do shell script "echo " & quoted form of current_phone & " | sed -e 's/+//g'" end repeat end repeat end tell </pre>
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hi V.K.
no error here, works a treat.
Budgie
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
well, for me it chokes up on the first contact with several phone numbers all containing + signs. It fixes the first phone number but errors out on the second one. the error message is: current_phone not defined
Message was edited by: V.K.
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I origionaly tested using only one phone number in x amount of contacts, just re-tested using multiple phone numbers in multiple contacts, still runs sweet here.
Budgie
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Try:
<pre style=" font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; margin: 0px; padding: 5px; border: 1px solid #000000; width: 720px; color: #000000; background-color: #FFDDFF; overflow: auto;" title="this text can be pasted into the Script Editor"> tell application "Address Book" repeat with Acontact in people repeat with APhone in (get phones of Acontact) set current_phone to value of APhone set value of APhone to do shell script "echo " & quoted form of current_phone & " | sed -e 's/+//g'" end repeat end repeat end tell</pre>
Check the AppleScript Language Guide Commands Reference for get, specifically the part about Object Specifiers toward the end.
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗