I'm trying to rename multiple files contain same string but of different file types. I have 20 case folders. Each on contain two type of files (*.nii and *.mat). They all contain the same string in the file name (say "reo-"). I hope to rename all of them to "rest.nii" and "rest.mat" respectively and put them in their original case folder.
I don't know how to keep the extension when rename the file. So I'm trying to use the code bellow to rename one type of file then another.
for files in `find . -type f -name '*.nii' | grep reo
echo files $file
mv $file rest.nii
But I don't know what to add into the script to put the renamed files in their original directory.
Could anyone help to edit it? If anyone know how can I rename both types of file at once, it will be perfect. Thanks!!!