At 11:23 2003-07-03 -0700, Mark Ruder wrote:
(http://www.xray.mpe.mpg.de/mailing-lists/procmail/2002-07/msg00377.html),
but the timestamp is modified to the current date and time.
I would assume that your timestamp issue is because the new files are
stamped with the timestamps as they've been rewritten by procmail. I don't
run maildir format, so I'm not very intimate with the various ways that it
can ruin your life.
Use of find, along with touch (see 'man touch') could resolve that.
For starters, you'd use the -r param of touch, and specify the file from
the source tree:
find $TEMPDIR -type f -exec touch -r {} ;\
That's an INCOMPLETE invocation - you need the target filename after the
braces and before the semicolon. The more difficult part is parsing the
file parameter for the destination filename... As I'm a bit busy trying to
remain financially afloat, I can't spend the time right now to look further
into this, but the above (and the script below) should be a start for you.
Here is the script I am using -
(quoted from the provided link)
#!/bin/sh
MAILDIR=$1
You have no contingency for dealing with an omitted parameter, and since a
null string for MAILDIR will result in absolute root path references, it
seems either requring an argument or defaulting the string to "." would be
a good idea. Perhaps you should add the following BEFORE this:
if [ "$1" = "" ]; then
echo "Usage: $0 maildir"
echo "$0 reprocesses mail through a procmail script."
exit
fi
for file in $(find $TEMPDIR); do
procmail $PROCMAILRC < $file
done
find can '-exec' a program directly, so the above can easily be
replaced with the single line:
find $TEMPDIR -type f -exec sh -c "procmail $PROCMAILRC < {}" \;
This certainly isn't more efficient shell-wise (if it weren't for the
redirection operator, you wouldn't need to invoke sh though), but the type
operator is significant (and you could just add that to your shellscript
invocation above) - I rather doubt you want to include directory links in
the mess. Note that escaping of the semicolon is necessary (well, it
rather depends upon your shell, but many shells, including bash, interpret
it as a delimiter for command chaining) - FIND expects it as part of the
invocation for -exec.
rm -fr $TEMPDIR
It would be wise to make that a MANUAL step performed AFTER you've checked
the output. Additionally, if temp EXISTED ALREADY (or was in use by a
concurrent and probably unrelated process), you're going to REMOVE THE
OTHER CONTENT - without so much as a confirmation prompt!
Other than that, sure, looks cool.
The rewritten script would appear like:
#!/bin/sh
# maildir reprocessing script
# 20030703/1401 SBS - revision to script from old procmail list post
if [ "$1" = "" ]; then
echo "Usage: $0 maildir"
echo "$0 reprocesses mail through a procmail script."
exit
fi
MAILDIR=$1
PROCMAILRC=~/.procmailrc
# now, let's make a unique temp filename
# (this not only generates the unique name, but creates the directory as well)
TEMPDIR=`mktemp -d $HOME/mail.reprocess.XXXXXX` || exit 1
mv $MAILDIR/cur/* $TEMPDIR
mv $MAILDIR/new/* $TEMPDIR
# run through the dir and reprocess the files therein.
find $TEMPDIR -type f -exec sh -c "procmail $PROCMAILRC < {}" \;
# okay, that's done, now let us run through the tree and tweak filetimes.
# (as above)
# all done
echo "process complete. After verifying everything is kosher, you should"
echo "manually invoke: rm -fr $TEMPDIR"
#--------------------------------------------------------------------------
I should point out that as I do not run maildir, I haven't live tested this
script myself - however, since it doesn't PURGE the tempdir, it isn't
anywhere nearly as lethal as the original script could be.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail