One procmail recipe to rule them all

I subscribe to a number of mailing lists from Debian. Since this generates a lot of emails, I want each list to end up in a separate folder on my mail server. This is pretty basic procmail filtering; just add one recipe for every list and be happy :) . But when you subscribe to a new list you’ll have to add a new recipe. Why not let procmail deal with it instead?!

There are procmail recipes out there that do that. But I want the first letter in the list name to be upper case, and when I wrote the following recipe I couldn’t find any that did that. I’m now publishing it, hoping that someone will find it useful. It should be pretty straightforward, but if you have any questions about it, just leave a comment or mail me and I’ll try to answer them.

# Match all debian lists and move them
# to Maillists/Debian/Listname
# Converts first letter in listname to upper case.
:0
* ^List-Id:.*<debian-\/[^.]*\.lists\.debian\.org>
{
        saved = $SHELLMETAS
        SHELLMETAS
        FIRST = `expr "$MATCH" : '\(.\).*'`
        LIST  = `expr "$MATCH" : '.\([^.]*\).*'`
        SHELLMETAS = $saved
        FIRST = `echo "$FIRST" | tr [:lower:] [:upper:]`
        :0
        .Maillists.Debian.$FIRST$LIST/
}
Posted Tuesday, January 11th, 2005 under programming.

Comments are closed.