Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Clean up quoted and swapped Address Book entries Apps
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.)

 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 
    •    
  • Currently 2.00 / 5
  You rated: 4 / 5 (6 votes cast)
 
[9,964 views]  

Clean up quoted and swapped Address Book entries | 0 comments | Create New Account
Click here to return to the 'Clean up quoted and swapped Address Book entries' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.