procmail
[Top] [All Lists]

Re: create sub-subfolders from $MATCH

2004-06-07 12:54:23
On Sun, 06 Jun 2004 15:31:55 +0200, Michelle Konzack
<linux4michelle(_at_)freenet(_dot_)de> wrote:
Am 2004-06-04 14:22:12, schrieb Scott Wiersdorf:
Note that the intermediate directory (a-z, etc.) must already exist:
procmail will not create it for you (it will only create the final
directory).

The directories already exist... 3469a-z

In case they don't, or might not, here's a way around it (Code based
on a thread in this list):

# put mail in $DIRNAME/$MYDATE.$LISTNAME
# e.g. procmail-list/2004-01.procmail
:0
* ! LISTNAME ?? ^^^^
{
   LOG="List: $LISTNAME$NL"
   :0: $HOME/lock
   $MLDIR/$DIRNAME/$MYDATE.$LISTNAME

   # if the action failed, probably the directory does not
   # exist, so create it
  
   :0eW
   {
     LOG="FAILED WRITE, MAKING $DIRNAME$NL"
     MAKENEWDIR=`test -d $MLDIR/$DIRNAME || mkdir -p $MLDIR/$DIRNAME/`
   }

   # Now save the message again
   :0a:
   $MLDIR/$DIRNAME/$MYDATE.$LISTNAME

   # If we get this far, something is quite wrong. (never gotten here)
   # Probably the permisions on $MLDIR are wrong.
   # Still failed?  Better save the message somewhere we can check it
   :0
   {
     LOG="FAILED WRITE NEW DIRECTORY$NL"
     :0: $HOME/lock
     $MLDIR/FAILED_LIST_SORT
   }
}

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