-
-
Save lsloan/4a822a2c4739247918678c0b94fb12bc to your computer and use it in GitHub Desktop.
Convert MH mail folders to MBOX files, which are used by Mozilla Thunderbird.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# mh2mbox.sh | |
# By Eric Lathrop <[email protected]> | |
# | |
# Convert MH mail folders to MBOX files | |
# Useful for switching to Mozilla Thunderbird | |
# | |
# Copy this script to ~/Mail/ and execute. | |
# | |
# Requires the "packf" command from the nmh package in Ubuntu | |
DEST="mbox" | |
# Note: in Ubuntu, packf gets installed under /usr/bin/mh/ so it's not normally in the $PATH | |
PACKF="/usr/bin/mh/packf" | |
(IFS=' | |
' | |
for DIR in `find . -type d`; do | |
if [ "$DIR" = "." ]; then | |
continue | |
fi | |
if [ "$DIR" = "./$DEST" ]; then | |
continue | |
fi | |
CONVDIR="." | |
if [ `dirname $DIR` != "." ]; then | |
CONVDIR=`dirname "$DIR" | sed -e "s/\.\///" | sed -e "s/\//.sbd\//g"`'.sbd' | |
fi | |
mkdir -p "$DEST/$CONVDIR" | |
MAILBOX=`basename $DIR` | |
MBOXPATH="$DEST/$CONVDIR/$MAILBOX" | |
# create an empty file in case there aren't any messages | |
# this fixes a thunderbird problem where it won't show subfolders | |
# for a folder that doesn't have a matching file | |
touch $MBOXPATH | |
yes | $PACKF +"$DIR" -mbox -file $MBOXPATH | |
done | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated as according to suggestion at: https://gist.github.com/ericlathrop/4982676#gistcomment-2222576