Find duplicate Address Book entries via a script

Mar 27, '06 05:35:00AM

Contributed by: nibaq

I was looking for an AppleScript that would just show me the duplicate entries in my Address Book, and not delete them out of hand, since some have different information yet the same name. I could not find one, but found this great gem from Apple Developer Documentation - Apple Script:

osascript -e 'tell app "Address Book" to get the name of every person' \
| perl -pe 's/, /\n/g' | sort | uniq -d
It will give you a nice listing of every duplicate entry in the Address Book, making it easier to sort through them for information and delete them individually.

[robg adds: Address Book's Card: Look for Duplicate Entries feature doesn't provide much information at all prior to merging -- it will just say "one duplicate card was found; do you want to merge this data?," without telling you which cards are duplicates. This script will let you verify which cards may be merged, prior to doing so. Note that the script is based simply on name matches, so you may see more duplicates listed via its ouput than you would with Address Book's duplicate feature.]

Comments (18)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060322202753429