I built the following script: #/bin/bash
VROOT="/usr/local/virtual/"; for i in `ls -d ${VROOT}*@*` ; do echo "`date`" echo "Processing ${i}" J_PATH="${i}/.Junk" H_PATH=${i}/"NotJunk" if test -d ${J_PATH}; then /usr/local/bin/sa-learn --spam -u vpopmail "$J_PATH/{new,cur}" else echo "No $J_PATH" fi if test -d ${H_PATH}; then /usr/local/bin/sa-learn --ham -u vpopmail "$H_PATH" mv "$H_PATH/{cur,new}/*" ${VROOT}${i}/cur else echo "No $H_PATH" fi echo "" done And it appears to work fine, except that it takes 20 seconds to process an entirely empty folder ---OUTPUT Sun Mar 11 13:17:24 MDT 2012 Processing /usr/local/virtual/ben@… Learned tokens from 0 message(s) (0 message(s) examined) Sun Mar 11 13:17:44 MDT 2012 ---END # ls -lsR /usr/local/virtual/ben\@…/.Junk/ total 6 2 drwx------ 2 root vpopmail 512 Mar 8 04:21 cur 2 drwx------ 2 root vpopmail 512 Mar 8 04:21 new 2 drwx------ 2 root vpopmail 512 Mar 8 04:21 tmp /usr/local/virtual/b...@xanmax.com/.Junk/cur: total 0 /usr/local/virtual/b...@xanmax.com/.Junk/new: total 0 /usr/local/virtual/b...@xanmax.com/.Junk/tmp: total 0 This seems like a lot of time for sa-learn to process 0 files. Long enough that I probably need to add some logic to check for actual files before passing the directory to sa-learn. Is this sort of delay normal? As for the logic, I was thinking of something like this: ISSPAM=`find "$J_PATH/{cur,new}" -type f` if [ ! $ISSPAM ]; then /usr/local/bin/sa-learn --spam -u vpopmail "$J_PATH/{new,cur}" fi -- I can't die, I haven't seen The Jolson Story