Moving files which are generating time to time

Hi all,

I always getting great response from this forum, that why i am putting again....

I am working in a company which is giving ATM support.In one of my production server a lot of files are getting generated every day. I want to move these files to another name.

The file name which is generating is something like "67234.KBL.121.ejournal.20090208_2256.txt", in which '121' is ATM UNIQUE ID. A lot of files are generating every day with different UNIQUE ID. There is a corresponding TERM ID for each unique ID.
Suppose UNIQUE ID 121 is having a term ID like "KBL1201" . The same way there is more than 150 UNIQUE ID's and its corresponding TERM ID's

So my ultimate aim is to change the file name to something like "KBL1201.DATE.txt" ie, files should change it's name corresponding to its TERM ID.

Thanks in advance
Renjesh Raju

Hello Renjesh

I understood your problem but before offering you any solution i would like to know whether there is a flat file which contains the mapping of unique id(ATM id) to terminal id.

If there is a flat file for the mapping. Please post it contents for reference.

Thank you for your reply

Yes i have a flat file which can link b/w TERM ID and UNIQUE ID.

For e.g .. (Content of the file is like )

121,KBL1201
132,KBL0321
145,KBL2100
......... and so on

Thanks
Renjesh Raju

Something like this would work for you

for i in `ls xyz`
do
ATM_ID=`cut -d"." -f3 $i`
TERM_ID=`grep $ATM_ID flat.txt|cut -d"," -f2`
mv $i ${TERM_ID}.DATE.txt
done

flat.txt is the file containing the mapping of ATM id and unique id
I am assuming that your files are getting generated in xyz dir.

Thank you for your reply...

Anyway still i am not getting the output. The script is throwing an error like
Cannot read the file (It is not able to read the file properly)

Thanks
Renjesh Raju