procmail
[Top] [All Lists]

Re: How can I save a message to a file named by its subject ?

1997-09-02 09:38:35
lapalmee(_at_)CRM(_dot_)UMontreal(_dot_)CA (Ervig Lapalme) writes:
      I am unable to do this:

I assume that by "unable" you mean to say that you aren't sure how you
can do it.


I want to save every message from `tweet` in a file containing
the subject of this message.  If the subject is `erv-vole-12-23-43`, I
want to save this message in a file `erv-vole-12-23-43.sgf`.

The following recipe requires procmail 3.10 or later.

        :0:
        * ^From:.*\<tweet\>
        * ^Subject: *\/[-a-z0-9_]+
        $HOME/some/directory/$MATCH.sgf

The first condition makes sure the message has a From: address containing
the word "tweet".  The second condition makes sure the first thing in the
subject is a letter, number, underbar, minus sign, and if so, it extracts
the longest possible run of those sort of characters starting at that
first one.  I.e., if the subject was:

        Subject: some random text

then it would extract "some", stopping at the space.  If the subject was:

        Subject: *something* big

it would fail to match at all.  If the subject was:

        Subject: this-could-be(but-isn't)a_test

then it would extract "this-could-be", stopping at the open paren.

Anyway, the action then tells procmail to deliver the message (assuming
the conditions matched) to a file in directory "$HOME/some/directory"
with the filename composed of the text extracted from the Subject with
".sgf" appended to it.


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>