[comp.mail.mh] Migrating MH folders to elm mailboxes ?

indra@amdcad.AMD.COM (Indra Singhal) (01/06/88)

I have 3 months worth of mail, all in mh style
folders which are directories with numeric msg
names.
	I have heard raves about the elm system
and would like to check it out first-hand. I
dont want to loose the structure of my mail
folders. Are there any existing conversion
techniques ?
	Thanks in advance !!
-- 
(-:-)                                                        (-:-)
-I said so... & said it for myself.             Indra K. Singhal
{ucbvax,decwrl,allegra}!amdcad!indra or amdcad!indra@decwrl.dec.com

taylor@hplabs.HP.COM (Dave Taylor) (01/06/88)

Indra Singhal asks how to take MH folders and translate them into
folders that Elm will like.

This turns out to be rather simple, actually.  The key is that you want
to have all the files `catted' into a single master file, so you can
go into the MH folder subdirectory and then type:

	% alias mk-folder   'cat * >! $cwd:t'

to get a folder created in a given subdirectory with the same name as
the directory.  That is, say you have a folder/directory called "inbox".
The following commands:

	% cd inbox
	% mk-folder

will result in your having an Elm-style [*] folder called "inbox" within
the directory.  You can then invoke Elm with something akin to:

	% elm -f inbox

to read it in.  Then you should try the various sorting options and
all (type `O' to get into the Options screen)...

In any case, that's how it could be done easily.

						-- Dave Taylor
						Hewlett-Packard Labs

[*] Elm folders are in essentially the same format as Berkeley Mail (etc)
    folders too - the only difference is that Elm doesn't require a blank
    line between messages.

marvit%hplpm@HPLABS.HP.COM (Peter Marvit) (01/07/88)

Dave's response is mostly correct (since he's the author of Elm.  Hi, Dave.),
although you need a bit more processing than simply a "cat".  Elm (and mailx)
looks for the 'From ' delimiter (or for mailx, '\nFrom') which MH strips.

To get an MH folder into a state readable by elm (with a *very* simplistic csh
script, try the following (spaces are important):

	cd ~/Mail/inbox     #or whatever folder
	foreach msg ( `ls [1-9]*` )
	cat "From null Wed Jan  6 00:00 PST 1988" >> /tmp/elm-msgs
	cat $msg >> /tmp/elm-msgs
	end
	elm -f /tmp/elm-msgs
	
Of course, if you wanted to permanently convert from MH to Elm, you'd probably
want to massage the messages to get a better "From " line.

I leave it to the philosophers as to which is better, MH or Elm.

-Peter "MH=Mail Heaven, Elm=Extremely Lovable Mailer" Marvit
 HP Labs

scott@tekcrl.TEK.COM (Scott Huddleston) (01/08/88)

mhpath is often better than shell globbing for converting MH message specs 
to unix file names.  Besides being more robust, mhpath orders message names
numerically, whereas globbing orders them alphabetically.  Changing
>	cd ~/Mail/inbox     #or whatever folder
>	foreach msg ( `ls [1-9]*` )
to
	foreach msg ( `mhpath +inbox all` )	#or whatever folder
In article <1599.568513624@hplpm> marvit%hplpm@HPLABS.HP.COM (Peter Marvit) 
gives the following improved script for converting an MH folder to an
Elm-readable file  (spaces in the From line are important):

	foreach msg ( `mhpath +inbox all` )	#or whatever folder
	cat "From null Wed Jan  6 00:00 PST 1988" >> /tmp/elm-msgs
	cat $msg >> /tmp/elm-msgs
	end
	elm -f /tmp/elm-msgs

rsalz@bbn.com (Rich Salz) (01/13/88)

I've just had occasion to transfer my mail archives from MH6.5 running on
Ultrix2.0 over to MailTool running on SunOS3.4.  This is the script I used
on the Sun.  It worked OK -- I (unfortunately :-) didn't seem to lose any of
my mail archives.
	/r$

#! /bin/sh
##  MHtoMT.  MH to UnixMail conversion.  Example:
##	MHtoUM personal
##  Reads all messages in MH directory ./personal, and creates the
##  Unix Mail folder ~/F/personal.
##  Assumes everything else has been cleaned out but MH folders.

X="`date | sed -e 's/^... //'`"
F=$HOME/F
cd $HOME/Mail
for D in ${1-*} ; do
    if [ ! -d ${D} ] ; then
	echo Skipping ${D} -- not a directory
	continue
    fi
    cd ${D}
    for I in `ls | grep -v '[^0-9]' | sort -n` ; do
	 T=`grep '^Date:' <${I} | head -1`
	 Z=`echo $T | sed -e 's/Date:[^,]*, //' -e 's/Date: //'`
#	 echo $I Date is @"$Z"@ >&2
	 if [ -z "${Z}" ] ; then
	     Z="${X}"
	 fi
	 echo ""
	 grep -v '^Replied:' <$I | \
	 sed -e "/Return-Path:/s=\$= ${Z}=" -e "/Return-Path:/s//From /"
    done >${F}/${D}
    cd ..
done
-- 
For comp.sources.unix stuff, mail to sources@uunet.uu.net.