Rename Multiple Files

I have a number of files

/u01/PROD/arch.PROD.1_1
/u01/PROD/arch.PROD.1_2
/u01/PROD/arch.PROD.1_3

I would like a simple method for moving/renaming them

/u01/TEST/arch.TEST.1_1
/u01/TEST/arch.TEST.1_2
/u01/TEST/arch.TEST.1_3

Note the only thing that changes is the PROD to TEST, in file and dir name.

I need to this in a script, so loops are fine, will be run via cron, the file numbers change daily. They will not always have the exact _1, _2, _3, this is an incremental number.

Any help?

#!/bin/ksh

cd /u01/PROD
for file in arch*; do

newfile=`echo $file | sed 's/PROD/TEST/'`
mv $file ../TEST/$newfile

done

This will rename every *PROD* file in the PROD directory to a corresponding *TEST* name in the TEST directory.

HTH

[Edited by PxT on 11-14-2000 at 11:42 AM]