Philip Guenther's recommendation to jzc(_at_)sibs(_dot_)com read, in part,
| :0 a
| {
| # I'm paranoid, let's have COUNT be at least 3 digits wide
I'd call that good planning, not paranoia. It's a rare day when I get
fewer than 100 letters.
| :0
| * COUNT ?? ^..$
| COUNT=0$COUNT
|
| :0 e
That should be `E', not `e'.
| * COUNT ?? ^.$
| COUNT=00$COUNT
| }
Another method, cheaper on processes but longer on disk space, would involve
naming a directory for `date +%y%m%d`, saving there to mh-style folders, and
using $LASTFOLDER to derive the message index number. We'll keep the indi-
vidual files in those directories as small as possible (one byte, in fact).
It would go something like this:
:0c
* conditions for this stuff
file_where_incoming_originals_are_stored
:0A
{
TODAY=`date +%y%m%d`
:0fw # Form reply headers and lose body (intentionally) in one process:
| formail -rt
:0bc # if today's directory already exists, this should succeed
$TODAY/.
:0e # if it failed, there is a new day to initialize
{
:0hwic # remove all old counter directories and create one for today
| rm -rf [0-9][0-9][01][0-9][0-3][0-9] ; mkdir $TODAY
:0bc
$TODAY/.
}
:0 # most common if you get 19-188 messages in a typical day
* LASTFOLDER ?? /\/..^^
{ MESSAGENUMBER=${TODAY}0$MATCH }
:0E # in case you ever get 1000 or more messages in a day, let it grow
* LASTFOLDER ?? /\/...
{ MESSAGENUMBER=$TODAY$MATCH }
:0E # can happen at most nine times in a day
* LASTFOLDER ?? /\/.^^
{ MESSAGENUMBER=${TODAY}00$MATCH }
# Alternatively, you could accept message numbers of the form 960213/1,
# 960213/2, and so forth, and just assign MESSAGENUMBER=$LASTFOLDER instead
# of using the preceding block of assignment recipes. Also, we won't have to
# worry about the width.
:0bfwi
| echo "Message number: $MESSAGENUMBER" ; echo ; cat autoreply.txt
:0
! -t
}
If you're willing to use month abbreviations instead of numbering the months
in your message numbers, you can build $TODAY out of the From_ line and not
have to run date(1). In fact, a series of .procmailrc recipes could trans-
late three-letter the month abbreviation extracted from the From_ line into
two digits or two letters without running an outside program.