Here’s my first foray with a script for finding a character in the address book and removing it. Several years ago an iOS app populated the suffix field with an Apple character for iPhone users. This functionality became part of iOS 6.0 with a iPhone field. I want to remove the Apple character from my Address book with over 2000 contacts.
tell application "Address Book"
repeat with i from 1 to (count every person)
set suffixProperties to properties of suffix of person i
repeat with j from 1 to (count of suffixProperties)
if value of item j of suffixProperties contains "" then
set value of item j of phones of person i to ""
log person
end if
end repeat
end repeat
save
end tell
This script complies; yet throws an error on “set suffixProperties to properties of suffix of person i.”
Please let me know if you have any ideas to achieve this goal in Applescript. I am not looking for vcf export solution; find and replace.
Although neville310’s script seems to be trying to delete phone numbers, his accompanying explanation says he wants to remove Apple characters from the suffixes. He shouldn’t try your script unless he definitely wants to lose the numbers!
Edit: Here’s a script which removes Apple characters from suffixes. if a suffix consists solely of an Apple character, it’s cleared by being set to ‘missing value’ instead.
tell application "Contacts" to set theSuffixes to suffix of people
set astid to AppleScript's text item delimiters
repeat with i from 1 to (count theSuffixes)
set thisSuffix to item i of theSuffixes
if (thisSuffix contains "") then
if (thisSuffix is "") then
set newSuffix to missing value
else
set AppleScript's text item delimiters to ""
set tis to thisSuffix's text items
set AppleScript's text item delimiters to ""
set newSuffix to tis as text
end if
tell application "Contacts" to set suffix of person i to newSuffix
end if
end repeat
set AppleScript's text item delimiters to astid
tell application "Contacts" to save