Here is a little kludge that I use to refile MH mail (e.g. I refile inbox
spam into inbox.suspect).  You can process your mbox files by using MH
"inc" to extract the messages, and MH "packf" to pack them into mbox format.

Your linux box probably has nmh installed already.

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

#!/usr/bin/perl

$HOME = $ENV{'HOME'};
$ME = $ENV{'USER'};

$doit = 1;
$local = "";
$folder = 'inbox';

# unbuffer stdout
$| = 1;

#
# keep a log
#

open(LOG, ">>$HOME/.deasser.log") || die("cannot append to log file");
$time = localtime;
print LOG "$time begin ", join(" ",@ARGV), "\n";

#
# parse arguments
#
while ($ARGV[0] =~ /^[-+]/) {
        if ($ARGV[0] eq "-n") {
                $doit = 0;
                shift;
        } elsif ($ARGV[0] eq "-L") {
                $local = "-L";
                shift;
        } elsif ($ARGV[0] =~ /^\+/o) {
                $folder = substr($ARGV[0], 1);
                shift;
        } else {
                die("unrecognized flag $ARGV[0]\n");
        }
}

#
# pick the files
#
$wd = "$HOME/Mail/$folder";
open(PICK, "pick +$folder @ARGV |");

#
# scan the files and decide where to put them
#
chdir($wd) || die("cannot chdir to $wd\n");
$count = $total = 0;
while (<PICK>) {
        chop;
        $FILE = $_;
        next if ($FILE eq "0");
#       if (system("$HOME/bin/spamc -c < $FILE >/dev/null") != 0*256) {
        if (system("$HOME/bin/spamassassin $local -e < $FILE >/dev/null") != 0*256) {
                $folders{$FILE} .= " +$folder.ass";
                $count++;
        }
        $total++;
}

#
# groups the files by destination
#
sub numerically { $a <=> $b; }
foreach $FILE (sort numerically keys %folders) {
        for ($fold = $folders{$FILE}; length($destinations{$fold}) > 500; $fold .= " 
") {
                # limit refile commands to about 500 characters each
        }
        $destinations{$fold} .= " $FILE";
}

#
# perform the refiles
#
foreach $destination (sort keys %destinations) {
        $cmd = "refile -unlink -src +$folder $destination 
$destinations{$destination}\n";
        $cmd =~ s/  +/ /g;
        print($cmd);
        print LOG "$time $cmd";
        if ($doit) {
                system("rm", "-f", "$HOME/Mail/$folder/.mh_sequences");
                system($cmd);
        }
}

$percent = $total>0?100*$count/$total:0;
print "# refiled $count of $total = $percent %\n";
print LOG "$time end refiled $count of $total = $percent %\n";

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


-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to