Duplicate Address Book entries search using AppleScript

Mar 14, 2010 · 2 min read

For quite sometime now I've been struggling with lots of duplicate entries in my Address Book, that was a result of - 

  • Syncs from Treo to BB and then to iPhone. 
  • Syncs from .mac, my trusty companion since 2005 - PB-G4-12", intel Mac and a MacBook from'03. 
  • Syncs of contacts from LinkedIn, Yahoo and GMail on a regular basis. 

Believe it or not, there are so many places you end up creating contacts that after a while it becomes really cumbersome to manage contacts. Finally, as a weekend project I decided to get rid of duplicates - and here's an interested script that I came across - that allowed me to sift through duplicates while not deleting them right away.  Hope this helps everyone out, though you can easily find the script on Mac OS X Hints as well.  Having a built-in feature within Address Book to deal with this issue would certainly help - or better yet within iPhone itself. 

(*REVISED FOR 10.6

Details found at - http://www.macosxhints.com/article.php?story=20060322202753429

Written by © Mark Hunte - 2009*)

tell application "Address Book"

set biglist to {}

set theGroup to "Dupilicate Entries"

if not (exists (group "Dupilicate Entries")) then

make new group with properties {name:"Dupilicate Entries"}

save

end if

set the_names to name of people

repeat with i from 1 to number of items in the_names

set theName to item i of the_names

if theName is not in biglist then

copy theName to end of biglist

else

set counter to (people whose name is theName)

if (count of counter) > 1 then

repeat with i from 1 to number of items in counter

set this_item to item i of counter

add this_item to group theGroup

end repeat

save

end if

end if

end repeat

end tell