Convert maildir to mailbox

I’m currently migrating my maildir based-mutt configuration to Thunderbird 2, therefore I had to convert the maildir based structure to mailbox files.

I found the inspiration for this little script in the forum of macosxhints: Converting Maildir to Mbox

#!/bin/bash
echo search mdir-files in $1 and send them to mbox: $2
for file in `find $1 -type f`
do
echo parsing: $file
cat $file | formail >> $2
done

It should be used for each “maildir-mailbox”, except you don’t mind having all your mails in one single file ;)

One Response to “Convert maildir to mailbox”

  1. Rupert Swarbrick Says:

    Just in case anyone wants to use this on a maildir that has been cloned by e.g. offlineimap and has subdirectories, they probably don’t want it to catch those subdirectories when they’re listing the INBOX. The solution is to replace the find command above with

    find $1 -maxdepth 2 -type f

    which seems to work for me.