#!/bin/ksh set -e [[ -z $1 ]] && print \$1 missing && exit 1 [[ ! -d $1 ]] && print folder $1 does not exist && exit 1 [[ ! -r $1 ]] && print folder $1 is not readable && exit 1 [[ ! -d $HOME/Maildir ]] && print $HOME/Maildir does not exist && exit 1 [[ ! -d $1/cur ]] && print $1/cur does not exist && exit 1 [[ ! -d $1/new ]] && print $1/new does not exist && exit 1 [[ ! -d $1/tmp ]] && print $1/tmp does not exist && exit 1 [[ ! -f $HOME/.procmailrc ]] && print no $HOME/.procmailrc found && exit 1 print cleaning-up $HOME/Maildir/msgid.cache... \\c rm -f $HOME/Maildir/msgid.cache && print done tmp=`find $1/tmp -type f` [[ -n $tmp ]] && print there is something in $1/tmp/ -- clean-up first && exit 1 find $1/cur $1/new -type f | while read msg; do print $msg... \\c formail < $msg | procmail && rm -f $msg && print done done print everything should be clean: find $1/ -type f #find $1/cur $1/new $1/tmp -type f print rm -rf $1