Renaming of multiple files with current date

Hi,

I have a fixed 4 files in each different directory. The total 17 directories are there each one having 4 files inside it. I need rename all of them with current date. The files formates will be as below:

Folder1:
abc_NOR_xyz_ddmmyyyy.txt
abc_NOR_ghij_ddmmyyyy.txt

Folder2:
abc_CAN_xyz_ddmmyyyy.txt
abc_CAN_ghij_ddmmyyyy.txt..etc.

Could you please help me in this regards.

Thanks,
Janardhan.

Are ddmmyyy in the files having other dates?
if yes, Do you mean to want the current date in place of "ddmmyyyy" ??

deleted

Using ksh something like

#!/bin/ksh
today=$(printf "%(%d%m%Y)T" now)

echo "$today"
# fix filegeneration if needed. My example has done in main directory and 
# those 17 directories are subdirectories
for f in */abc_???_???_????????.txt
do
       # parse line using delimeter _ and .
        echo "$f" | IFS="_." read part1 part2 part3 partdate end str
        partdate="$today"   # newdate value
        newname="${part1}_${part2}_${part3}_${partdate}.${end}"
        [ -f "$newname" ] && echo "$newname already exist" >&2 && continue
        # remove echo after you have tested
        echo mv "$f" "$newname"
done
#!/bin/bash
ls | while read file
do
	echo mv $file ${file%_*}_$(date +%_d%m%Y).${file#*.}
done

If you like the output remove the echo

Yes...ddmmyyyy will be old date. I need to replace ddmmyyyy with current date for all the files.