displaying duplicate contacts

I’m trying to display duplicate contacts

I can find them like this ,


tell application "Address Book"
	set listOfContacts to every person whose first name is "joe" and last name is "Shmoe"
end tell

but I can’t seem to figure out how to get address book to open them up so the user can compare the duplicates so they can determine what to keep

thsnks for help

mm

Hi mm,

maybe it’s not necessary to reinvent the wheel :wink:
http://www.hawkwings.net/2006/03/30/removing-duplicate-entries-in-address-book/

Or, in plain vanilla AS:

tell application "Address Book" to set N to name of every person
set D to {}
set NT to {}
repeat with I in N
	if contents of I is not in NT then
		set NT's end to contents of I
	else
		set D's end to contents of I
	end if
end repeat
end

Now search for the names in D and choose one, deleting the other.

Wow, thanks you both, I guess there is no what to just open the contacts up in new windows for someone to manually review them with out having to search them out and flip back and forth between them ?

if not one of your solutions will have to work!!

Again thanks for the help I appreciate it

mm

Address Book doesn’t have a “New Window” command. You can only see one at a time. The possibilities for what you might want to know are large too, so a nice presentation of all the data for two would be quite messy to construct. Besides, running my version, I’ve eliminated the two dupes that showed up :slight_smile:

so heres what I ended up doing and don’t get me wrong I don’t like to GUI script


tell application "Address Book"
	set firstName to "Joe"
	set lsatname to "Shmoe"
	set listOfContacts to every person whose first name is firstName and last name is lastName
	if (count of listOfContacts) is greater than 1 then
		activate
		delay 1
		tell application "System Events"
			tell process "Address Book"
				keystroke "f" using command down
				keystroke firstName & space & lastName
					keystroke tab
					delay 1
					keystroke tab
					delay 1
					keystroke tab
					delay 1
					keystroke "a" using command down
					keystroke return
			end tell
		end tell
	end if
end tell