procmail
[Top] [All Lists]

Re: Rerun procmail filters on maildir folder.

2002-07-24 09:29:42
"David W. Tamkin" <dattier(_at_)ripco(_dot_)com> writes:
Alex Polite (whom I should introduce to the Dave Rude I know from another
list) asked,

| I had an error in my procmailrc, landing 200 messages in the wrong
| maildir directory. Now I want to rerun procmail on all messages in
| that directory.

cd that_directory
cat * | formail -s procmail

Unlike the case of reprocessing an mbox, you don't have to worry about getting
into a loop here.  If one of the first few messages to be processed lands back
in the same directory, the file with the new copy won't be in the expansion of
asterisk (which was made before the shell invoked procmail, or formail, or
even cat).

Messages written to a maildir folder don't have a leading "From " line,
so formail won't reliably split the output of 'cat'.  Instead, use a
for loop in the shell:

sh:     cd path/to/dir/new
        for file in *; do
                procmail < $file
        done

csh:    cd path/to/dir/new
        foreach file (*)
                procmail < $file
        end

As with David's version, the '*' is expanded before procmail is first
invoked so you don't need to worry about infinite loops with this.


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail