people how are you
How can I do to automatically rename a list of files, only modifying the date that it has in the name of the file, for the current day, without modifying the rest of the values??
I have a file that has the list, its content would be like this:
DASH_20210608175132_0000.msg
DASH_20210608175132_0001.msg
DASH_20210608175132_0002.msg
Manually it would be:
mv DASH_20210608175132_0000.msg DASH_`date +"%Y%m%d"`175132_0000.msg
mv DASH_20210608175132_0001.msg DASH_`date +"%Y%m%d"`175132_0001.msg
mv DASH_20210608175132_0002.msg DASH_`date +"%Y%m%d"`175132_0002.msg
mv DASH_20210608175132_0003.msg DASH_`date +"%Y%m%d"`175132_0003.msg
In this way I only change what I need the date in the file mask.
But I would like to automate this procedure, how could I do it?
You could separate the file names with a
cut
:The commented lines is because I don't know if you are going to read the list from a file or execute it with a
ls
. Either way, you can always pass anwhile
after to it with a pipe.