No need for the subjects file. In bash, just cd into that dir and:
for SUBJ in $(ls -1); do SOURCE_FILE="${SUBJ}/dwi/${SUBJ}_dwi.nii.gz"; if [ -f "${SOURCE_FILE}" ]; then mv "${SOURCE_FILE}" "${SUBJ}/dwi/dwi.nii.gz" && echo "File moved for subject $SUBJ."; else echo "File not found for subject $SUBJ, skipped."; fi; done
Will also give some feedback.
Best,
Tim
> On July 3, 2019 at 2:23 PM Benjamin Stott <[log in to unmask]> wrote:
>
>
> Dear FSL users,
>
> I have a main directory (project) containing 652 subject subdirectories (sub-001, etc.). In each of these is a subdirectory (dwi) containing a single NIFTI file (sub-001_dwi.nii.gz). I hope this makes sense!
>
> I would like to remove the subjects ID from each of these NIFTI file names, e.g. sub-001_dwi.nii.gz --> dwi.nii.gz, using a loop of some sort. I have made a .txt file with the subjects IDs (sub-001, sub-002 ... ).
>
> I'm very new to the FSL software and unix in general.
>
> Thanks for you help/suggestions,
> Ben
>
> ########################################################################
>
> To unsubscribe from the FSL list, click the following link:
> https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=FSL&A=1
--
Dr. Tim Schäfer
Postdoc Computational Neuroimaging
Department of Child and Adolescent Psychiatry, Psychosomatics and Psychotherapy
University Hospital Frankfurt, Goethe University Frankfurt am Main, Germany
########################################################################
To unsubscribe from the FSL list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=FSL&A=1
|