#!/bin/sh ########################################################################################### #The script written by Grifter from http://forums.debian.net #It scans your NH mailbox for deleted MH files (like ",1"), make them readable and put them #into the trash folder which you have to create. ########################################################################################### # Set this dir to be the location of where you want # the files moved, be aware that this should be the # dump for all deleted mails, it should not be an # existing mailbox that has to compete with 'real' # mails UN=/home/rex/Mail/trash # Set this dir to be the root of the mailstructure # you want to search for ",filenames" DEUX=/home/rex/Mail # Check for the latest mail, stripping the padding zeroes # (let doesn't preserve the padding zeroes, so we need to # re-pad them later on) VARCOUNT=`ls $UN | sed -r 's/(0*)(.*)/\2/' | tail -n 1` # Check if it's the first run, if not we'll let the var # iterate higher, so the next filename won't overwrite # the previous mail if [ -z $VARCOUNT ]; then VARCOUNT=00001 else let VARCOUNT+=1 fi # Just making sure something isn't funky if [ -f $VARCOUNT ]; then echo "ARRGH! File exists when it shouldn't! Funky Alert!" exit 1 fi # Here we start the loop to find ",filenames", when it finds one # it will test how many characters the current count has, first # testing for 5 characters where no padding is needed, if the # var doesn't have 5 chars it will test for 4, and pad one zero # infront of the count, otherwise it will continue down the list, # adding extra zeroes as needed, to make it 5 characters for i in $( find $DEUX -name ',*'); do if [ -n "`echo $VARCOUNT | grep .....`" ]; then mv $i ${UN}/${VARCOUNT} elif [ -n "`echo $VARCOUNT | grep ....`" ]; then mv $i ${UN}/0${VARCOUNT} elif [ -n "`echo $VARCOUNT | grep ...`" ]; then mv $i ${UN}/00${VARCOUNT} elif [ -n "`echo $VARCOUNT | grep ..`" ]; then mv $i ${UN}/000${VARCOUNT} elif [ -n "`echo $VARCOUNT | grep .`" ]; then mv $i ${UN}/0000${VARCOUNT} fi # ",file" has been renamed to VARCOUNT with leading zeroes if needed, now we # increase the count by one to prepare for the next iteration of the loop let VARCOUNT+=1 # Closing loop #End of Grifter's script. ############################################################################################ done