It doesn't strike me as a particularly good idea, but it's not hard to do. Just use the \/
capturing token to get the matching text into $MATCH
.
:0:
* ^From:.*(SOME EMAIL)
* ^Subject: \/SOME SUBJECT.*
| cat > "/SOME DIRECTORY/$MATCH.txt"
You say you save the body, but your recipe doesn't do that; it saves the whole message. (Add a b
flag if you want only the body in the file.)
Also note how I omitted the named lock file (it's more efficient to let Procmail figure out a lock file name in this scenario ... though locking probably deosn't matter all that much if you overwrite the file anyway) and the redundant .*
in the From:
regex. (It's not redundant in the Subject because you want to capture the entire header.)
This will of course fail if the Subject contains a slash and you don't have a corresponding directory name on disk.
If you don't want to overwrite, the default is to append, so no cat
is required or useful.
:0:
* ^From:.*(SOME EMAIL)
* ^Subject: \/SOME SUBJECT.*
/SOME DIRECTORY/$MATCH.txt