[172] in resnet

home help back first fref pref prev next nref lref last post

[yandros@MIT.EDU: Re: athena mailboxes]

daemon@ATHENA.MIT.EDU (jhbrown@MIT.EDU)
Sat Feb 5 03:56:09 1994

From: jhbrown@MIT.EDU
Date: Sat, 5 Feb 94 03:55:49 -0500
To: resnet@MIT.EDU


Here is an mh2babyl conversion script.  Have fun...

Jeremy

-------------------

#!/usr/athena/perl

# Convert mh folders to Rmail mail files. Outputs to files
# of the same name as the folder, with a .babyl extension.
# Usage: mh2babyl <folder> ...

$|++;				# no buffering

$header = <<EOH;		# Babyl header
BABYL OPTIONS:
Version: 5
Labels:
Note:   This is the header of an rmail file.
Note:   If you are seeing it in rmail,
Note:    it means the file has no messages in it.
\037
EOH

chop $header;			# get rid of the trailing newline

foreach $folder (@ARGV) {
    do {
	warn "$folder not a folder!\n";
	next;
    } unless -e $folder && -d $folder;
    print "Working on folder $folder...\n";
    
    # sort the mh files
    opendir(D, $folder) || die $!;
    @files = sort {$a <=> $b;} grep(/^\d+$/, readdir(D));
    closedir(D);

    # don't do anything if there aren't any files
    do {
	warn "No messages in folder $folder!\n";
	next;
    } unless @files;

    # make our output file
    ($outfile) = $folder =~ m#([^/]*)#;
    $outfile .= ".babyl";
    open(OUT, ">$outfile") || die $!;

    # write the header
    print OUT $header;

    # process the files
    foreach $file (@files) {
	print "$file ";
	open(IN, "<$folder/$file") || die $!;
	print OUT "\014\n0,,\n*** EOOH ***\n";
	while (<IN>) {
	    print OUT $_;
	}
	print OUT "\037";
	close IN;
    }
    print "\n";
    close OUT;
}




home help back first fref pref prev next nref lref last post