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


Click here to return to the 'Find duplicate Address Book entries via a script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Find duplicate Address Book entries via a script
Authored by: bromo on May 02, '11 04:25:57PM

Here is a slightly improved version of the duplicated finder script. This script will handle embedded special characters correctly. (O'Reilly will parse properly among others) It works case independently so John Smith and John smith will appear as duplicates. Finally it prefixes each duplicated name with a number indicating how many times the name is duplicated.


osascript -e 'set result_list to ""'
-e 'tell application "Address Book" to repeat with i_ref in (get name of every person)'
-e 'set result_list to result_list & quoted form of contents of i_ref & linefeed'
-e 'end repeat'
| sort -f | uniq -ci | grep -v '^ *1 '

BTW the unix pipeline at the end creates a sorted list with one entry for each name prefixed by the number of entries that have a match to the name. The grep command then filters out all the entries that have only 1 matching entry.



[ Reply to This | # ]
Find duplicate Address Book entries via a script
Authored by: dgerrity on Nov 13, '11 03:17:51PM
That is fantastic! Thank you. BTW it's hard to read the options to uniq -- they are dash c as in show count, and i (eye) as in case insensitive.

[ Reply to This | # ]