#!/bin/bash mdirname='cur' find . -name $mdirname | while read from; do nm=`dirname $from | sed 's/[^a-zA-Z0-9]/-/g; s/^-*//; s/--*/-/' ` echo "Converting $from into $nm" /bin/ls -1 "$from" | while read message; do echo -n `cat $from/$message | grep '^From:' | head -n1 | sed 's/.*<([^>]*)>.*/From 1/'` date '+%a %b %e %H:%M:%S %Y' cat $from/$message | sed 's/^From /From:/' done > $nm.mbox done