procmail
[Top] [All Lists]

Re: Rerun procmail filters on maildir folder.

2002-07-25 09:28:23
Alex followed up,

| But I will end up with multiple copies of the same msg, no?

Yes; you didn't say whether you wanted to keep the original deliveries or not,
so Philip and I both left that issue alone.

| This snippet takes care of that.
| _____________________________
| #!/bin/sh
| MAILDIR=$1
| TEMPDIR=$(mktemp -d)
| PROCMAILRC=~/.procmail/procmailrc.m2

Is /bin/sh on your system a shell that groks tildes and $(...) command
substitution?  Pure sh wouldn't understand either, but often /bin/sh is a link
to bash or zsh or ksh and there would be no problem.

| mv $MAILDIR/cur/* $TEMPDIR
| mv $MAILDIR/new/* $TEMPDIR
| for file in $(find $TEMPDIR); do

Instead of running find,

 for file in $TEMPDIR/* ; do

|   procmail  $PROCMAILRC < $file
| done
| rm -fr $TEMPDIR

Yes, that would get rid of the original deliveries, but you'll have to be very
cocksure that the redeliveries are working out.  I'm not that confident.
Something like this would invoke rm more often, but I'd personally be more
comfortable with it:

 TEMPDIR=$(mktemp -d) # trusting Alex, have never heard of mktemp before
 mv $MAILDIR/cur/* $MAILDIR/new/* $TEMPDIR

 for file in $TEMPDIR/*
 do
  procmail $PROCMAILRC < "$file" && rm "$file"
 done

For that matter, the temporary directory and the call to mv are unnecessary:

 for file in $MAILDIR/cur/* $MAILDIR/new/*
 do
  procmail $PROCMAILRC < "$file" && rm "$file"
 done

| Thanks a lot to both of you.

You're very welcome.  Good luck.



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