Hi,
I have little experience on Shell scripts, I searched the forum but couldn't make out what I want.
I want to rename a set of files to a new file name
a_b_20100101
c_d_20100101
.......................
......................
I want to rename the files to
a_b_20140101
c_d_20140101
Could you please help to achieve this?
I have a set of 2000 files
if rename works then
rename _2010 _2014 *2010*
clx
3
with sed,
ls *2010* | sed 's/\(.*\)_\([0-9]\{4\}\)\(.*\)/mv \1_\2\3 \1_2014\3/g'
Edit : This will print the mv oldfile newfile
to the screen. You can redirect it to a file, take a look and if all ok, source the file with
. command_file
1 Like
thanks man for the support
Yoda
5
An approach using shell builtins:
for file in *_2010*
do
mv "$file" "${file/_2010/_2014}"
done
1 Like
Another way:
ls *_2010*| sed -e "p;s/_2010/_2014/"|xargs -n2 mv
1 Like