procmail
[Top] [All Lists]

Re: date filtering of old messages

2003-01-22 04:49:12

Regarding b) maybe someone already has a recipe for this (detecting 
messages older than "today minus nn days"?
 
 One way of doing this is using GNU date (from sh-utils) to convert the
 date into "seconds since the epoch"

     %s   seconds since 00:00:00, Jan 1, 1970 (a GNU extension)

 and then perform a simple numerical comparison.

#
Date=/opt/gnu/bin/date

# Comparison date; remove all msgs older than this
CDATE="Wed, 1 Oct 1997 00:00:00"
# GNU date supports relative date strings as well, e.g.
#CDATE="5 days ago"
# Comparison date in "seconds since 1 jan 1970"
CDATE_NUM=`$Date -d "${CDATE}" '+%s'`

# Date of current msg
# Do not use Date: header, use From_
FDATE=`formail -x "From " | sed 's/^\([A-Za-z0-9\(_dot_)(_at_)-]*\) 
\([A-Za-z0-9: ]*\)/\2/'`
FDATE_NUM=`$Date -d "${FDATE}" '+%s'`

:0:
* ? test ${CDATE_NUM} -gt ${FDATE_NUM}
OLDMAIL


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