Count only option, if you just want to know how many would be deleted.
This commit is contained in:
parent
7f8e60a7ee
commit
074f2979e8
1 changed files with 7 additions and 5 deletions
|
@ -23,12 +23,12 @@ use warnings;
|
||||||
use Mail::Header;
|
use Mail::Header;
|
||||||
#use File::Copy;
|
#use File::Copy;
|
||||||
|
|
||||||
if (@ARGV < 3) {
|
if (@ARGV < 3 or @ARGV > 4) {
|
||||||
print STDERR "usage: $0 <MAILDIR_DIRECTORY> <DSPAM_PROBABILITY_MIN> <DSPAM_CONFIDENCE_LEVEL_MIN>\n";
|
print STDERR "usage: $0 <MAILDIR_DIRECTORY> <DSPAM_PROBABILITY_MIN> <DSPAM_CONFIDENCE_LEVEL_MIN> [<COUNT_ONLY_DONT_DELETE>]\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
my($MAILDIR_FOLDER, $DSPAM_PROB_MIN, $DSPAM_CONF_MIN) = @ARGV;
|
my($MAILDIR_FOLDER, $DSPAM_PROB_MIN, $DSPAM_CONF_MIN, $COUNT_ONLY) = @ARGV;
|
||||||
|
|
||||||
my($total, $countDeleted) = (0, 0);
|
my($total, $countDeleted) = (0, 0);
|
||||||
|
|
||||||
|
@ -68,9 +68,11 @@ MAIL: foreach my $dir (@msgDirs) {
|
||||||
if ($dspamVal{Confidence} >= $DSPAM_CONF_MIN and
|
if ($dspamVal{Confidence} >= $DSPAM_CONF_MIN and
|
||||||
$dspamVal{Probability} >= $DSPAM_PROB_MIN) {
|
$dspamVal{Probability} >= $DSPAM_PROB_MIN) {
|
||||||
$countDeleted++;
|
$countDeleted++;
|
||||||
|
if (defined $COUNT_ONLY and $COUNT_ONLY) {
|
||||||
warn "unable to unlink $dir/$file : $!"
|
warn "unable to unlink $dir/$file : $!"
|
||||||
unless unlink("$dir/$file") == 1;
|
unless unlink("$dir/$file") == 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
close MAIL_MESSAGE;
|
close MAIL_MESSAGE;
|
||||||
}
|
}
|
||||||
close MAILDIR;
|
close MAILDIR;
|
||||||
|
|
Loading…
Add table
Reference in a new issue