Going Maildir

Thursday, 13 Nov 2003

All my mailboxen are in Maildir format now. Since I didn’t like any of the existing conversion options, I rolled my own using the safecat utility in 3 minutes:

#!/bin/bash
for MBOX in "$@" ; do
  [ -d "$MBOX" ] && continue
  [ -e "$MBOX" ] || continue
  mv "$MBOX"{,.bak}
  mkdir -p -m 700 "$MBOX"/{tmp,cur,new}
  formail -s safecat "$MBOX"/{tmp,cur} < "$MBOX".bak
done

It is obviously imperfect, but did the job for me anyway. For more complex requirements, you can just open the mailbox in mutt, tag all messages and copy them to the Maildir mailbox. This is tedious and not easily automatable though, so I only used this approach for 3 of my three-dozen-odd mailboxen.