I seem to have wound up with many entries in my Address Book that contain quotes in the names, or have commas in their name with the first and last names swapped.
I wanted to clean this up, so I wrote an AppleScript that removes all quotes from address book entries, and swaps first and last names in names containing commas.
Save this script in Script Editor, and run it. (Backup your Address Book first just to be safe; File > Back up Address Book.)
I wanted to clean this up, so I wrote an AppleScript that removes all quotes from address book entries, and swaps first and last names in names containing commas.
Save this script in Script Editor, and run it. (Backup your Address Book first just to be safe; File > Back up Address Book.)
tell application "Address Book"
set quoted to (people whose name contains ",")
repeat with aquote in quoted
set nlast to my removeText(first name of aquote, ",")
set nfirst to my removeText(last name of aquote, ",")
set first name of aquote to nfirst
set last name of aquote to nlast
--exit repeat
end repeat
set quoted to (people whose name contains "\"")
repeat with aquote in quoted
set first name of aquote to my removeText(first name of aquote, "\"")
set last name of aquote to my removeText(last name of aquote, "\"")
end repeat
end tell
on removeText(completeTxt, removeTxt)
repeat while completeTxt contains removeTxt
set rePos to the offset of removeTxt in completeTxt
set len to (length of completeTxt)
if rePos is not 0 then
if rePos > 1 then
set tmpTxt to ((characters 1 through (rePos - 1)) of completeTxt) as string
else
set tmpTxt to ""
end if
if rePos + (length of removeTxt) < len then
set completeTxt to tmpTxt & (characters (rePos + (length of removeTxt)) through len of completeTxt) as string
else
set completeTxt to tmpTxt
end if
end if
end repeat
return completeTxt
end removeText
•
[9,962 views]

