I am trying to rename nifti files, aiming to keep the first 15 characters of filename (which are random and indicate subject id) and rename the rest of the file to "scan_name.nii.gz"?
for i in `ls ${dir}/nifti_loc`; do echo ${i};
for j in `ls ${dir}/nifti_loc/*MPRAGE*.nii.gz | grep -v -i AXI`; do
cp ${j} ${dir}/nifti_loc/rename/${j}\_mprage.nii.gz;
done;
done;