Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to organize all incoming email into the following directory structure based on the date of the email:

ROOT --+-- YYYYMMDD --+-- HH --+-- mm --+-- YYYYMMDD-HHmmSS-000001
       |              |        |        |
       |              |        |        |      ....
       |              |        |        |
       |              |        |        +-- YYYYMMDD-HHmmSS-NNNNNN
       |              |        +-- mm --
       |              +-- HH --+-- mm -- 

Note that each email will be stored as a separate file and the name of the file is YYYYMMDD-HHmmss-NNNNN, where NNNNN is a running number.

Can procmail or maildrop do this? If not, what other options are there?

Thanks in advance.

share|improve this question

This can be achieved using procmail. Here is an example .procmailrc:


DATE=`date +%Y%m%d`
HOUR=`date +%H`
MIN=`date +%M`


# Creates the slice if necessary.
DUMMY=`test -d $MAILDIR/$SLICE || mkdir -m 700 -p $MAILDIR/$SLICE`

Subtlety: the slash after $DEFAULT indicates Maildir format. If you prefer mbox instead, remove it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.