Aswex
1
Hello,
I am looking for a command line that will rename name files :
f700_abc_o_t_MASTERID_AS_AE_20130323.csv
like this
f700_abc_o_t_MASTERID_AS_AE_20130324.csv
The great idea could be to get the date stamp
20130323
and change any part of it, instead of just change the last number, if possible.
Thanks
PikK45
2
basename "f700_abc_o_t_MASTERID_AS_AE_20130324.csv" .csv | awk -F"_" '{print $NF}'
Hope this will help
Aswex
3
Thanks PiKK45, but this wont work as all files dont have the same name.
The only part that doesn't change is the date stamp in the file name.
And this is the part a need to change in the file name.
Any idea ?
it's about 100 files to change ...
PikK45
4
Considering all the filenames will have the same YYYYDDMM in their names, you can loop 'em all
ls | while read file
do
newfile=$(echo $file | sed 's/20130323/20130324/g' )
mv $file $newfile
done
1 Like
anbu23
5
for file_nm in *
do
ext=${file_nm##*.}
mv $file_nm ${file_nm%_*}"_"$(date +%Y%m%d)"."${ext}
done
1 Like