1 year ago

#383683

test-img

Muhammad Elsadany

How to rename multiple files in Linux?

I want to rename my files in linux from

sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-20161127175734_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-20161127175734_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-20161127180331_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-20161127180331_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-20161127173234_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-20161127173234_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-20161127173809_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-20161127173809_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-rest_run-20161127164822_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-rest_run-20161127164822_bold.nii.gz

to be

sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-1_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-1_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-2_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-MID_run-2_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-1_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-1_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-2_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-nBack_run-2_bold.nii.gz
sub-NDARINVKW1ALL48_ses-year0120161127_task-rest_run-1_bold.json
sub-NDARINVKW1ALL48_ses-year0120161127_task-rest_run-1_bold.nii.gz

Can anyone help? I have a list of similar files in different directories too. So, I want it to be a generic code that I can use, if possible.

linux

rename

0 Answers

Your Answer

Accepted video resources