I have two hierarchies of mbox mail, one is the 'live' one (called Mail) and the other is the archive (called MailArchive). I want to set up a cron job such that all mail that I save in the Mail hierarchy will also be automatically merged into the MailArchive hierarchy. This then allows me to delete old mail from the Mail hierarchy safe in the knowledge that it's archived.
The Mail and MailArchive hierarchies have the same basic filenames and structure so a simple 'sledgehammer' approach is to do the following:-
Use 'find' to traverse the Mail hieararchy.
For each mbox file run 'formail' on both the Mail and the MailArchive mbox into a temporary file
Run 'formail' on the temporary file to remove duplicates and put the result in place of the MailArchive mbox.
Can anyone think of a more elegant way of doing this? Actually I think I've thought of one possible improvement, I can avoid that second 'formail' by adding the remove duplicates option to the first 'formail' pass. In fact that would seem to be reasonably efficient now I come to think of it.
(... and don't anyone say use Maildir, I have moved to using Maildir several times over the past few years and every time I return to mbox after a few weeks. Maildir just isn't so easy to live with, for me at least)