How do you remove duplicate contact groups -- I have thousands of them (Answered below)

They appear on iCloud -> contacts

iPhone -> contacts

MacOS -> contacts


They appear to have accumulated over the years, all the same group name of "Work".


====

Answer:

I tried deleting the contact groups by hand on iCloud -> contacts:

  • For the first one: left-click on the group-name, type the delete key, type return
  • This leaves the next group-name selected, type the delete key, type return <-- repeat until tired

they were deleted, it takes about 2-3 seconds per contact

but there were thousands and thousands of them.


So I used "automator" which is built-in Mac tool to automate deleting them (and indeed found there were about 5000 identical contact-groups):

  • Get a contacts window
    • Safari -> iCloud.com, login, select "Contacts" and move that window off to the left.
  • Run your automator script:
    • start automator (finder -> applications -> automator)
    • create a new automator script
    • move the automator window over to the right, and resize this window and the Safari window so they don't overlap
    • hit the automator "record" red button (automator records the mouse/key sequences you do)
      • mouse to "All Contacts" in the iCloud contacts window
      • left-click on "All Contacts" twice (the first time sets the input focus, the second one selects the group)
      • down-arrow twice to move the selected group down to one you want to delete
      • hit the delete key
      • hit the return key
    • hit the automator "record" button to stop recording
    • hit automator "run" and the script should run and remove a group
    • save the script (as a checkpoint that works)
    • add an automator "loop" to repeatedly run the above script
      • In the automator library menu down the left side of the window click on "Utilities" which should reveal a submenu with "Loop"
      • Drag the Loop into the automator script window under the main script box.
      • Set "Loop automatically", Stop after 5 times, Use the original input
      • Adjust "Playback speed" to about .5x, and the Timeout to "15 seconds".
    • Run your script that now includes a loop (click on run) and watch the fun.
    • if it works fine, restart everything and run it:
      • change the loop count to something large (I used 1000), save the script, exit automator
      • close/exit Safari
      • start automator, and select your saved-script
      • start Safari -> iCloud.com -> contacts
      • hit automator -> run, and come back in a few hours and see how it went.


The automator tool's behavior was a little inconsistent, I had problems when I:

  • tried to select the contact group I wanted to delete instead of "All contacts" and arrowing down. I would have expected this to work, sometimes it did, but unfortunately... sometimes it didn't
  • did not restart between runs. Sometimes it worked, sometimes it hung
  • once it deleted the third contact instead of the third contact-group. I don't know why or how -- maybe I accidentally touched the mouse while the script was running (?,?) but fortunately iCloud contacts keeps a backup of your contacts and you can revert to a prior version.
  • I ran the script too fast (hence the adjustment of "Playback speed" and Timeout.


It took about 50 hours of run time over several days to delete all the groups.


Note: the above handles the case where all contact-group names are the same, and you want to delete them all. You'll have to adapt this if that isn't your situation.


Good luck!

June 2021


MacBook Pro (2020 and later)

Posted on Jun 28, 2021 8:43 AM

Reply

Similar questions

1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do you remove duplicate contact groups -- I have thousands of them (Answered below)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.