On Thu, Jan 03, 2002 at 09:36:01AM -0500, giorgian wrote:
> if i have two mail folders and want to merge them in one avoiding
> repetitions, how can i do?
I had to do this recently. The way I did it was to copy the messages
from both folders into a third, and then remove any duplicates in this
third folder. I did the latter using "formail" which is a utility that
comes with procmail (see "man formail"). Below is a quick Python script
that automates the process.
#!/usr/bin/env python2.1
#
# a script that dumps duplicate emails from an mbox file
import sys
import os
cache_size = 32676
cache_file = '/tmp/msgid.cache'
# check the args
if len(sys.argv) < 2:
print 'Need to provide a filename of an mbox to clean.\n'
sys.exit(-1)
fname = sys.argv[1]
# backup the original
os.system('cp -a "%s" "%s.bak"' % (fname, fname))
# make sure there is no old cache
try:
os.unlink(cache_file)
except OSError:
pass
# not a problem, just means there was no cache
# run formail
os.system('formail -D %d %s -s < "%s.bak" > "%s"\n' % (
cache_size, cache_file, fname, fname))
--
Maciej Kalisiak [EMAIL PROTECTED] www.dgp.toronto.edu/~mac