🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.mail.mh
Article #1982

Re: Converting MH back to mbox

#1982
From: John Romine
Date: Thu, 22 Feb 1990 19:02
61 lines
2400 bytes
(David Disser) writes:
>Is there any way to convert MH messages all back into one file that could
>be read via mail -f?

"packf" packs messages into the so-called "ms" format (messages delimited
with lines of four control-A's.)  I believe "mail -f" wants to see them
delimited with "\n\nFrom <user> <ctime>".  A simple shell script could
easily do this, however.  Something like:

	for i in `mhpath +folder messages`
	do
		echo "From noone `date`"
		cat $i
		echo ""; echo ""
	done > outputfile

>I have a lot of old messages cat'd into one big file
>which I've compressed to save space.  What I want to to is break it back
>down into mbox format or individual MH messages.

If you didn't delimit the messages somehow, it's going to be tough.
Usually, "Received:" is the first header in a message so I'd check
for that as a pseudo-delimiter.  If you've used MH on these messages,
there may be annotations preceeding the "Received:" lines, so you'll
have to check for those as well. (i.e. Forwarded:, Replied: , etc.)
Modifiy the script below as needed.

Here's a script which does a rough job of it.  Extract this somewhere
and run:

	awk -f xtr.awk < inputfile > msgbox
	inc -file msgbox

Of course, if you have any forwarded messages present, they'll be extracted
individually, with any trailing text.

Cheers,
/JLR

: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
echo 'Extracting xtr.awk'
sed 's/^X//' > xtr.awk << '+ END-OF-FILE xtr.awk'
X/^Received:/ && m == 0 {m = -1}		# beginning of new message
Xm == -1 {
X	if (n++ > 0)
X	    printf "%c%c%c%c\n", 1, 1, 1, 1
X	printf "%c%c%c%c\n", 1, 1, 1, 1
X	m = 1
X}
X	{print}
X/^$/	{m = 0}		# end of headers
XEND	{ printf "%c%c%c%c\n", 1, 1, 1, 1 }
+ END-OF-FILE xtr.awk
chmod 'u=rw,g=r,o=' 'xtr.awk'
echo '	-rw-r-----  1 jromine       243 Feb 22 10:57 xtr.awk        (as sent)'
echo -n '	'
/bin/ls -l xtr.awk
exit 0
--
John Romine
Technical Details
Message-ID: <25E43740.25548@paris.ics.uci.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!usc!ucla-cs!uci-ics!jromine
References: <1522@zipeecs.umich.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!usc!ucla-cs!uci-ics!jromine
From: jromine@ics.uci.edu (John Romine)
Newsgroups: comp.mail.mh
Subject: Re: Converting MH back to mbox
Message-ID: <25E43740.25548@paris.ics.uci.edu>
Date: 22 Feb 90 19:02:25 GMT
References: <1522@zipeecs.umich.edu>
Reply-To: jromine@ics.uci.edu (John Romine)
Organization: UC Irvine Department of ICS
Lines: 61