7 unshift(@INC, $ENV{'DELIVERPATH'});
8 require 'audit.pl' || die "$program: cannot include audit.pl: $@";
9 require 'mh.pl' || die "$program: cannot include mh.pl: $@";
14 '-except "+folder..."',
27 ($folder = shift @ARGV) if ($ARGV[0] =~ /^\+/);
31 defined($SW{'help'}) && do {
32 print "syntax: $program [+folder] [switches] [-exec MH command]\n";
38 #if (!defined($folder)) {
39 # $mailpath = $MH{'path'} . '/';
40 # $folder = `mhpath`; chop $folder;
41 # $folder =~ s|^$mailpath|\+|;
45 @args = (($program =~ /s$/) ? ("-all") : ( ));
46 for ('all', 'recurse', 'norecurse') {
47 push(@args, "-$_") if defined($SW{$_});
51 if (defined($SW{'exec'})) {
54 exec "folder $folder @args";
58 $path = `mhpath $folder`; chop $path;
59 die "$0: unable to change directory to $path: No such file or directory.\n"
63 open(FOLDERS, "folder $folder @args -fast -noheader |") || die
64 "$0: cannot find list of folders: $?";
66 @exceptions = split(' ', $SW{'except'});
71 for $ef (@exceptions) {
72 ($f = $ef) =~ s/^\+//;
73 next SKIP if ($_ =~ m|$f|);
74 $f = `mhpath +$f`; chop $f;
75 next SKIP if ($_ eq $f);
78 if (defined($SW{'clean'})) {
79 $contents = `folder +$_ -total`;
80 if ($contents =~ /\s+0\s+messages/) {
81 print "removing empty folder +$_...\n" if defined($SW{'verbose'});
82 $f = `mhpath +$_`; chop $f;
83 rmdir($f) unless defined($SW{'debug'});
88 print "@command +$_ \n" if defined($SW{'verbose'});
89 system "@command +$_" unless (defined($SW{'debug'}));