Joined: 17 Feb 2011
|Posted: Sun Apr 03, 2011 4:13 pm Post subject: Convert Windows mail to mbox format for import
I wrote some scripts some weeks ago to convert my Windows Live mail to mbox (for import into Claws, Evolution or Thunderbird).
In fact, the Windows Live mail stores its mails in separate files. The first line always starts with "From: ", so I only needed to remove the ':' and to concatenate the files. To keep my folders, I created one mbox-file for each Windows mail folder. Because this still left me with too many files to import (I had a lot of folders), I also wrote a second script that takes mbox files together in one file and puts the name of the folder in the Subject line.
The first script (copy past this to wm2mbox):
if [ $# -ne 2 ]
echo "Usage: wm2mbox <windowz-mail-dir> <output-dir>"
echo "Converts Windowz mail to mbox-files"
echo "First argument: your Windows mail directory"
echo "Second argument: output directory (must be different) !"
echo "One mbox-file will be generated for each Windows Mail folder, e.g."
echo "Inbox.mbox, Sent Items.mbox, ..."
echo "Example: wm2mbox /mnt/vista/users/admin/"
wmd="$1" # windows mail directory
oud="$2" # output directory
# Remove trailing /
# Create clean output directory
if [ -d "$oud" ]
rm -v "$oud"/*.mbox
# Enumerate local folders
find "$wmd"/"Local Folders" -mindepth 1 -type d | while read dir
echo -n "Converting $fld... "
# find "$dir" -maxdepth 1 -type f -name "*.eml" -size +1c |
ls "$dir" | grep "eml$" |
while read msg
sed -e '1s/^Return-Path: //
1s/^ */From /
echo " $nbr done."
The second script concatenating different mbox files
if [ $# -lt 2 ]
echo "usage: mboxsbj <mxob-files>"
echo "purpose: add the name of each file to the subject, to import the different files at once"
echo "The following will concatenate the Audit and Info mboxes to All.mbox and "
echo "[Audit] or [Info] as first word on the Subject line:"
echo " \$ mboxsbj Audit.mbox Info.mbox >All.mbox"
sed -e "s/^Subject:/Subject: [$l] /" "$f"
I hope this can help people within their transition from Windows to Linux.