There are many ways in doing it... one is based on the time the file created in the system and the other way is based on date in the file name...
There will be a problem with the first method if the latest file ftp'd before the old files... old files will have latest file creation date than latest files and will move latest files to the archive folder...
Hence I adopted the second method which archives the file based on the date in the file name... hope this helps.
Code:
#!/usr/bin/ksh
for name in $(ls acme* | sed 's/_[0-9]*.txt//g' | uniq)
do
cnt=0
for fname in $(ls $name* | sed 's/_\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/_\3\1\2/g' | sort -r )
do
echo $fname
nm=$(echo $fname | sed 's/_\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/_\2\3\1/g' )
cnt=$(($cnt+1));
if [ $cnt -ne 1 ]
then
mv $nm ./bkup
echo "$nm moved to backup"
fi
done
done