procmail
[Top] [All Lists]

Re: how to delete duplicate emails

2010-10-07 19:53:57
At 16:08 2010-10-07, Henry E. wrote:

I've got  duplicate messages in an email folder. The SA does not
know what's causing the issue.  So, I need to delete them
I read I can use the following command.  However it just deletes
all messages in the old folder and does not create the new folder.
If someone knows how this can be done, could they pls post
how to solve it.

formail -D 8192 msgid.cache < oldfolder >> newfolder

The formail command would be invoked from within a procmail recipe, not standalone at the commandline. See 'man procmailex', which provides an example of its usage for eliminating duplicates. BEFORE YOU IMPLEMENT THE RECIPE, BE SURE TO PURGE YOUR BOGUS msgid.cache FILE, OR EVERYTHING IN oldfolder WILL BE CONSIDERED A DUPLICATE (up to the constraints of the size of the cache at least).

This is using the messageid of the message - so you may have a message that passes through a mailing list AND is CC'd to you - despite having taken two separate paths to reach you, only the first to arrive will be maintained. That is, while a list message will have additional headers, and perhaps a list-inserted footer, it is ONLY the messageid that is used to identify that they are duplicates.

Also, could you suggest how to lock the oldfolder while doing
the formail.

Per the recipe in 'man procmailex':

:0 Whc: msgid.lock
| formail -D 8192 msgid.cache

:0 a:
duplicates

## uncomment this if running standalone
## change as necessary for maildir
#:0:
#new.mbx

If you want to take old mail and handle it, you'll need to put the above recipe into its own file and uncomment the recipe at the bottom, then invoke it with something like:

        formail -s procmail -m duplicates.rc < old.mbx

If you're dealing with maildir instead of mbx, you'll need to update the recipe to deliver to your maildirm MOVE your maildir to a new folder, then invoke procmail with each message.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>