On 2003.07.24 19:20, Chris J wrote:
Hmm it doesn't want to play nicelyWritten for ksh; will this do the job? It seems to work with some really really brief testing, so usual disclaimers apply :)
#!/usr/bin/ksh
LIST_ROOT="/home/simon/testmail1"
LISTDIR="${LIST_ROOT}/lists"
ARCHIVE="${LIST_ROOT}/archive"
LASTMONTH="${LIST_ROOT}/lastmonth"
months[0]='January'; months[1]='Febuary'; months[2]='March'
months[3]='April'; months[4]='May'; months[5]='June'
months[6]='July'; months[7]='August'; months[8]='September'
months[9]='October'; months[10]='November'; months[11]='December'
integer year
integer oldmonth
integer thismonth
year=`date +%Y`
thismonth=`date +%m`
oldmonth='(thismonth + 9) % 12'
[[ $oldmonth -gt $thismonth ]] && year=year-1
cd ${LASTMONTH}
if [ -f * ]
then
mkdir -p ${ARCHIVE}/${year}/${months[$oldmonth]}
mv ${LASTMONTH}/* ${ARCHIVE}/${year}/${months[$oldmonth]}
fi
cd $LISTDIR
if [ -f * ]
then
mv * $LASTMONTH
fi