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

A way to review duplicates in Contacts Apps
Today, I went to send a weekly email to a list I maintain in Contacts, and I noticed that my group had inexplicably lost 7 cards! So I restored the contact cards from Time machine, which allowed me to only "Keep New" ones. However, I ended up with more cards than I knew I was supposed to have.

So I tried using Contacts' "Look for Duplicates" feature, but it would not let me review the duplicates. It simply told me that I had 28 duplicate cards and 8 duplicate entries based on people having the same name, and offered to let me either select Merge or Cancel. I'd sorted out messy merges before, so I wasn't about to get into that morass. So I devised my own way of finding and reviewing duplicates.

First, I selected my group, clicked the name at the top, then Shift-clicked the last name to highlight all the cards. I then dragged them into the to field of an empty email. I then typed Command-A to select them again and pasted them into a temporary TextEdit plain text document which I named "dupe_search.txt". (If anyone knows a way to skip the email/drag step, let me know.) I then ran the text document through this set of piped commands in Terminal:
cut -f 2 -d '<' dupe_search.txt | cut -f 1 -d '>' | sort | uniq -c | grep -v "   1 "
This returns a list of email addresses with the number of times they occur in Contacts to the left. I then manually searched for each one in Contacts to inspect the dupes.

To merge the cards, select them and just type Command-Shift-| or select "Merge Selected Cards" from the Card menu.

I remembered after doing this that most of my missing cards had been a series of duplicates I'd previously merged a week ago! But I did recover 4 that had apparently slipped through Apple's cracks.

Be wary about maintaining lists in Contacts, especially if you use iCloud. I have found some disturbing bugs, such as when you right-click on a group and select "Send email to '...'", I wasn't getting the same number of email addresses as when I manually selected all the cards in that group and dragged them to the email! I've been adding emails via my iPhone - and I'm not sure I trust that iCloud is syncing them correctly given these four recovered cards!

[kirkmc adds: I haven't tested this. I have often had problems with Contacts, however, especially with certain cards having multiple email addresses that come from other cards. I wish there were a better way to clean out the Contacts database.]
    •    
  • Currently 3.11 / 5
  You rated: 1 / 5 (9 votes cast)
 
[7,463 views]  

A way to review duplicates in Contacts | 8 comments | Create New Account
Click here to return to the 'A way to review duplicates in Contacts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Just buy contacts cleaner.
Authored by: jfaughnan on Mar 18, '13 08:33:04AM

Contacts Cleaner isn't perfect, but it's pretty darned good. I've used it for a couple of years. it's available in the App Store.

---
--
John Faughnan
jfaughnan@spamcop.net
www.faughnan.com



[ Reply to This | # ]
Just buy contacts cleaner.
Authored by: j-beda on Mar 18, '13 10:06:14AM

It looks like "Contacts Cleaner" cannot work with CardDAV contacts (such as those in iCloud)

http://spanningtools.com/mac/contacts-cleaner-help.html

Q. Can Contacts Cleaner fix CardDAV contacts?
A. No. Unfortunately, Apple does not provide access to CardDAV-based contacts through its developer libraries.

It also has references in the FAQ to MobileMe, which makes it seem out of date as that service has not been available for quite some time.

The recent update (Dec 2012) does claim "Better Mountain Lion support" so maybe it does work with iCloud contacts, but they do need to update their support information if that is the case.



[ Reply to This | # ]
A way to review duplicates in Contacts
Authored by: dushu on Mar 18, '13 10:22:09AM

I generally sync the contacts with google and then run the find duplicates in google - it allows you to review duplicates and then merge...



[ Reply to This | # ]
A way to review duplicates in Contacts
Authored by: peterpk on Mar 18, '13 11:03:46AM

The poster asked for a way to eliminate the manual copy/paste. This Applescript ought to do it. It can be saved to a file, such as "listgroup.script", and then called from the command line as osascript listgroup.script >dupe_search.txt. Note that the group name is hardcoded right now, because this was done quickly.

tell application "Contacts"
        set myNames to name of every person in group "SomeGroup"
        set myEmails to value of first email of every person in group "SomeGroup"
        set mylist to {}

        repeat with m from 1 to count of myNames
                set end of mylist to ((item m of myNames & " <" &amp; item m of myEmails &amp; ">") as string)
        end repeat

        set tid to Applescript's text item delimiters
        set Applescript's text item delimiters to ASCII character 10
        get mylist as string
        set Applescript's text item delimiters to tid
end tell

Edited on Mar 18, '13 11:04:41AM by peterpk


[ Reply to This | # ]
A way to review duplicates in Contacts
Authored by: robleach on Mar 18, '13 11:37:05AM

Perhaps a droplet would be in order that creates the text file using the dropped contacts... or a script that gets selected contacts and exports the email addresses to a file. I like your scripting solution.



[ Reply to This | # ]
A way to review duplicates in Contacts
Authored by: robleach on Mar 18, '13 11:45:51AM

You know what? I just realized I'd forgotten a step:

After you drag the emails to text edit, you have to search and replace ", " (comma space) with a hard return. Copy and paste the hard return from one manually typed in the file into the replace text box.

Save, then you can run the command line series on the file.

Rob



[ Reply to This | # ]
A way to review duplicates in Contacts
Authored by: petersconsult on Mar 22, '13 02:50:55AM

Bento is also a solution for more 'fine-grained' contact management...
However, i'm not sure how it would handle iCloud

In any case, there's a demo (14 days, i think..)
http://www.filemaker.com/products/bento/



[ Reply to This | # ]
A way to review duplicates in Contacts
Authored by: robleach on Feb 04, '14 09:39:51AM

It appears that Mavericks (OS X 10.9.1) does not allow one to drag contacts from Address Book (now dubbed "Contacts.app") into the fields of an email anymore. Nor does it allow dragging from the "Address Panel" in Mail.app itself. You must click the field button in the "Address Panel" window of Mail.app after selecting the email addresses. Otherwise, this procedure just worked for me again to root out a handful of dupes.



[ Reply to This | # ]