I have a bunch of folders which look like the below, I need to remove the point between the 2.0:
0010_DWI_MS_2.0_first_2874028735_10.bvec
0010_DWI_MS_2.0_first_2874028735_10.bval
0010_DWI_MS_2.0_first_2874028735_10.nii
0011_DWI_MS_2.0_first_2874028735_11.bvec
0011_DWI_MS_2.0_first_2874028735_11.bval
0011_DWI_MS_2.0_first_2874028735_11.nii
What I'm trying to acheive:
0010_DWI_MS_20_first_2874028735_10.bvec
0010_DWI_MS_20_first_2874028735_10.bval
0010_DWI_MS_20_first_2874028735_10.nii
0011_DWI_MS_20_first_2874028735_11.bvec
0011_DWI_MS_20_first_2874028735_11.bval
0011_DWI_MS_20_first_2874028735_11.nii
Is there also a way to do this for folders rather than files?
CodePudding user response:
You may use this solution:
for d in *2.0*/; do mv "$d" "${d/2.0/20}"; done
This will move only directories containing 2.0
in their names.
CodePudding user response:
A sed
approach that removes the first . it encounters.
$ for i in "0010_DWI_MS_2.0_first_2874028735_10.bvec";do
echo "${i}" | sed -e 's/\.//'
done
0010_DWI_MS_20_first_2874028735_10.bvec