[comp.sys.next] Here's how to put news into Mail.app

das15@cunixa.cc.columbia.edu (Douglas A Scott) (05/06/91)

I had posted an awk script which was my first attempt at reformatting mboxes
and news mailbox-style files for the NeXT, but I just sat down and rewrote it
so that it works 98% of the time.  Just take any mbox that currently causes
Mail.app to barf (vax mboxes did, and so do all saved news mailboxes) and say

convert bad.mbox > good.mbox

save this script as "convert" (or whatever) and just run it as a shell script.

++++++++++++++++++++++++++++++++++++
$1 !~ /^Date:/ && $1 !~ /^From: /       { entry[line]=$0; line++;}
/^From: / {
	printf ("%s %s %s\n", "From", name, fromdate);
	print origfrom;
	print origdate;
	while(i < line-1) { print (entry[i]); i++;}
	i=0; line=0;
	printf ("\n\n\n\n");
	origfrom=$0;
	if ( $2 !~ /^[A-Za-z]/ ) name = substr($2,2,length($2));
	else name = $2;
	}
/^Date: / { origdate=$0;
	if ( $2 ~ /^[0-9]/ ) {
		if( length($7) == 0 ) $7="Sun";
		fromdate=sprintf("%s %s %s %s 19%s", $7, $3, $2, $5, $4) ;
	}
	else if ( $3 ~ /^[0-9]/ )
		fromdate=sprintf("%s %s %s %s 19%s", substr($2,0,length( $2)-1), $4, $3, $6, $5);
	else
		fromdate=sprintf("%s %s %s %s %s", $2, $3, $4, $5, $6);
	} 
' $1

This works much better than the old one!

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Douglas Scott          Columbia University Computer Music Studio 
Internet: <doug@woof.columbia.edu> <das15@cunixa.cc.columbia.edu>
UUCP: ...!columbia!woof!zardoz!doug          Phone: (703)765-4771

das15@cunixa.cc.columbia.edu (Douglas A Scott) (05/07/91)

Terribly sorry folks...I left off the first line of the awk shell script!
Here is the whole thing again:
----------------
awk '
$1 !~ /^Date:/ && $1 !~ /^From: /       { entry[line]=$0; line++;}
/^From: / { 
            printf ("%s %s %s\n", "From", name, fromdate);
            print origfrom;
            print origdate;
            while(i < line-1) { print (entry[i]); i++;}
            i=0; line=0;
            printf ("\n\n\n\n");
            origfrom=$0;
            if ( $2 !~ /^[A-Za-z]/ ) name = substr($2,2,length($2));
            else name = $2;
          }
/^Date: / { origdate=$0;
                if ( $2 ~ /^[0-9]/ ) {
                        if( length($7) == 0 ) $7="Sun";
                        fromdate=sprintf("%s %s %s %s 19%s", $7, $3, $2, $5, $4);}
                else if ( $3 ~ /^[0-9]/ )
                        fromdate=sprintf("%s %s %s %s 19%s", substr($2,0,length($2)-1), $4, $3, $6, $5);
                else
                        fromdate=sprintf("%s %s %s %s %s", $2, $3, $4, $5, $6);
          } 
' $1

Some people have reported having problems with this.  All it does is add one
new line at the beginning of each news mail article, beginning with the word
"From" followed by a space (no colon!), then the person's name, and a
specially formatted date (hence the fancy awk stuff for the date).  Perhaps
this script gets munged by rn?  Let me know if you have problems.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Douglas Scott          Columbia University Computer Music Studio 
Internet: <doug@woof.columbia.edu> <das15@cunixa.cc.columbia.edu>
UUCP: ...!columbia!woof!zardoz!doug          Phone: (703)765-4771