Hi All,
I have a requirement to archive processed file and retain the archive based on the quantity.. but this is in windows.
I have written a drafted shell script, and would like to have it translated into Batch script.. Please...
Below is the drafted shell script
===================================================
#!/bin/ksh
XCOUNT=$1
FILNME=$2
OUTDIR=$3
ARCDIR=$4
mv $OUTDIR/$FILNME $ARCDIR
cd $ARCDIR
### LIST THE FILES SPECIFIC TO THE FILENAME
ls | grep $FILNME > list.txt
### LOOP
while $XCOUNT > 0 ;
do
### GET THE OLD ARCHIVE
TMPFIL1=`grep $FILNME.$XCOUNT list.txt`
TMPFIL2=${TMPFIL1%.*}
if [[ ! -z ${TEMPFIL1} ]] &&
[[ $XCOUNT = $1 ]]; then
rm -f ${TEMPFIL1}
fi
## not sure if this will work.. but the logic is to subtract 1 :)
XCOUNT=$(($XCOUNT-1))
if [[ -z ${TEMPFIL1} ]]; then
continue
fi
mv $TEMPFIL1 $TMPFIL2.$XCOUNT
done
===============================================