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

Remove duplicate emails from Mail.app Apps
On several occassions in the past, problems with email clients, importing old email, downloading email again after some error, etc. has resulted in several duplicated emails. Rather than sifting through the entire list of emails searching for ones with the same subject and delivery time, I stumbled across this feature in Mail that does it almost automatically!

You can approach this one of two ways, one being a bit easier than the other. If you can select only emails and their duplicates and make sure not to select emails that have no duplicates, you can use the easy method. Just highlight all the emails and their duplicates (only!), click to switch to another email folder, then click back to the folder you had selections in. You should find that only one of each duplicated emails are selected so just click on delete to remove them.

If you either aren't sure if you have duplicates or not, or the duplicates are inconviently scattered throughout non-duplicated emails, this is a tiny bit more work but works. Create a new email folder -- call it "Temp" or something easy to remember/find.

Select all the email in the folder you want check. Click on another folder and return to the first. All non-duplicated and one of each duplicated emails are now selected. Drag them to the temporary folder you created. Return to the original folder and delete everything in there. Now just move all the email in the temporary folder back to the original and delete the temporary folder.

I'm not sure what causes it, but sometimes Mail will do something and deselect duplicate emails before I move to another folder, but I have not been able to figure out what causes Mail to do that, or recreate it, so moving to another folder is the quickest way I've found to deselect the duplicates.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[6,203 views]  

Remove duplicate emails from Mail.app | 4 comments | Create New Account
Click here to return to the 'Remove duplicate emails from Mail.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
less cumbersome method
Authored by: Lee Phillips on Oct 28, '02 11:14:46PM
I don't use Apple's Mail program, but I believe that it uses standard unix format mail files. In that case, all you have to do is make a shell script:
#!/bin/sh
formail -q -D 1000000 idcache  $1.bk
mv $1.bk $1
rm idcache
Run this with the name of your mail file as input, and it will zap the duplicates.

[ Reply to This | # ]
corrected script
Authored by: Lee Phillips on Oct 29, '02 09:09:52AM

It seems that the software that runs this site is broken, and mangled the script that I posted. I'll try again, submitting it this time as plain text:

#!/bin/sh
formail -D 1000000 idcache < $1 -s > ztmp && mv ztmp $1
rm idcache

If you save this somewhere in your executable path and call it "zap", then you just type

zap mailfile

to remove the duplicates from the mail file mailfile.



[ Reply to This | # ]
LF/CR
Authored by: david-bo on Oct 31, '02 01:01:45PM

Does this script handle Mac-line endings (^M) ? Eudora stores its mailboxes in mbox-format but with Mac-LF...



[ Reply to This | # ]
Brilliant!
Authored by: bobme on Oct 29, '02 11:21:36AM

<Sorry this is added in wrong place -- I've gone blind and can't see how to add a new comment>

Anonymous, your hint is brilliant! How did you ever discover this? I have been looking for a good way to remove dupes in Mail for a long time, and I even asked some Apple developers for thoughts. Who would have thought that it was already in there, undocumented??

Here is one subtlety to be aware of: I tend to have duplicate messages where sometimes the attachment has been omitted. The selection routine you describe will ignore the existence of attachments, and so it is likely that the "good" message will be one without the attachment. My simple fix is to go back to the original folder and copy over any msgs with attachments into the new temp folder. This will result in some dupes, but I avoid losing any attachments. Anyone have a better method?

Thanks,
Bob



[ Reply to This | # ]