How to change existing date to current date in a filename?

Suppose i have a list of files in a directory as mentioned below

1.  Shankar_04152019_ny.txt
2. Gopi_shan_03122019_mi.txt
3. Siva_mourya_02242019_nd.txt
..
.
.
.
.
1000 . Jiva_surya_02282019_nd.txt

query : At one shot i want to modify the above all filenames present in one path with current date as mentioned like below
Since todays date is :04172019

1.  Shankar_04172019_ny.txt
2. Gopi_shan_04172019_mi.txt
3. Siva_mourya_04172019_nd.txt.....etc

Kindly suggest me an unix script for this

What have you tried?
You need to loop over the files in the directory - the loop is not valid syntax; I'm trying to get you to understand how to solve your problem.
Sample works for Linux sed only

cd /path/to/files
loop
   # this section is usable syntax
   read filename
   newfilename=$(echo "$filename" |  sed -E 's/[0-9]{8}/04172019/g'  ) 
  #  mv $filename $newfilename    # # Remove the leading # when this works for you
  echo "$filename -> $newfilename"
end loop

You really should tell us your exact OS and shell.

1 Like

How to replace only date part to current date of all files present in diretory in unix Folder path : C:/shan Sample files:

CN_Apria_837p_20180924.txt
 DN_Apria_837p_20150502.txt
 GN_Apria_837p_20160502.txt
 CH_Apria_837p_20170502.txt
 CU_Apria_837p_20180502.txt
 PN_Apria_837p_20140502.txt
 CN_Apria_837p_20101502.txt 

O/p should be :

 CN_Apria_837p_20190502.txt
 DN_Apria_837p_20190502.txt
 GN_Apria_837p_20190502.txt
 CH_Apria_837p_20190502.txt
 CU_Apria_837p_20190502.txt
 PN_Apria_837p_20190502.txt
 CN_Apria_837p_20190502.txt

Updated question . I am new to unix so i couldn't able to figure out the script to work .Kindly someone help me out

You really should answer ALL questions asked in post #2. Your C:/shan path implys you're on a windows system. What's your *nix flavour, again? Your shell? And, when trying to apply / adapt jim mcnamara's pseudo code, where are you stuck?

I will move the all files to unix sever before manipulating the file name . It my mistake giving wrong path there.
My apologies for that..