procmail
[Top] [All Lists]

Re: create sub-subfolders from $MATCH

2004-06-04 14:58:07
On Fri, Jun 04, 2004 at 08:36:32PM +0200, Michelle Konzack wrote:
Hello, 

the regexp drives me crazy !!!

This works now:

  ____ ( /home/michelle/.procmail/bug-tracking-system ) ________________
 /
|  SP='   '
|  
|  :0
|  * ^To:.*(bug-tracking-system(_at_)freenet(_dot_)de)
|  * $ ^Subject:.*package \/[^$SP]+$
|  * $MATCH ?? ^\/[^$]+
|  BTS/$MATCH/
 \______________________________________________________________________

but I get to many (more then 1200) directories in =BTS and I like to 
make subfolders with the firs leter of a Package name like

BTS/a/a2ps
    b/bc
    ...
    x/xserver-xree86

How can I do that ?

I'm going to make nested blocks again (sorry David! But I'd be extra
impressed to see it w/o nested blocks):

  SP='   '

  :0
  * ^To:.*(bug-tracking-system(_at_)freenet(_dot_)de)
  * $ ^Subject:.*package \/[^$SP]+$
  * MATCH ?? ^\/[^$]+
  {
    ## save the folder name in FOLDER
    FOLDER = $MATCH

    :0
    ## save the first letter of the folder name in MATCH
    * FOLDER ?? ^\/.
    BTS/$MATCH/$FOLDER/
  }

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).

And what I does not unterstand, what the variable $SP does...

SP is (as above) the standard space and tab characters. By putting it
in a character class:

  [$SP]+

you're saying, "one or more spaces or tabs". By negating the character
class with '^':

  [^$SP]+

you're saying, "one or more characters (that are not spaces nor
tabs)".

And then I need for the PTS the same recipe but the header has only one 
one word like

X-Debian-PR-Package: procmail

  SP='   '

  :0
  * ^To:.*(bug-tracking-system(_at_)freenet(_dot_)de)
  * $ ^X-Debian-PR-Package:[$SP]*\/[^$SP]+$
  * MATCH ?? ^\/[^$]+
  {
    ## save the folder name in FOLDER
    FOLDER = $MATCH

    :0
    ## save the first letter of the folder name in MATCH
    * FOLDER ?? ^\/.
    PTS/$MATCH/$FOLDER/
  }

Same caveat for BTS: the PTS/$MATCH directory must exist. My original
reply to your query had an example of how to create that directory if
you don't know the directory already exists.

Please if you answer, write an small explanation why it is like you 
write because I must learn the stuff

I suggest you read Sean Straw's 'sandbox' method found at his website:

  <http://www.professional.org/procmail/sandbox.html>

and just try some of this stuff in a non-production environment;
you'll learn a lot. VERBOSE logs also help you see how procmail works.

Scott
-- 
Scott Wiersdorf
scott(_at_)perlcode(_dot_)org

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