#!/bin/sh # hendry@iki.fi # Show how many messags are in each folder # See http://trac.natalian.org/browser/home/.procmailrc # For configuration of how .lists folders are created # Use crontab like so: # @hourly /home/hendry/Mailtest/mailcheck.sh | sort -rg > /home/hendry/Mailtest/l.txt MAILDIR=/home/hendry/Maildir TOTAL=0 for i in `find $MAILDIR -maxdepth 1 -name ".lists.*" -type d` do RCOUNT=0 # read count NCOUNT=0 # new count DIR=`basename $i` [ -d $i/new ] && NCOUNT=`find $i/new -type f | wc -l` [ -d $i/cur ] && RCOUNT=`find $i/cur -type f | wc -l` # Delete empty list folders, procmail recreates them btw #echo -n NC: $NCOUNT #echo " RC: $RCOUNT" [ $NCOUNT -eq 0 ] && [ $RCOUNT -eq 0 ] && rm -rf $i printf "%5d %5d %s\n" $NCOUNT $RCOUNT $DIR #echo $NCOUNT $RCOUNT $DIR TOTAL=$(($TOTAL+$NCOUNT+$RCOUNT)) done #printf "%5d:%s\n" $TOTAL "TOTAL NUMBER OF MESSAGES"