0

I have a list of folder names in .txt file. I want the code to pick a name from text file, match in a directory, enter that folder and a subfolder and copy a file and paste it to another directory and also add folder name in front of the file name.

For an example I have folder name A, B, C and they have sub-folder name X, Y, Z respectively. I want the code to enter A folder and then sub-folder X and then copy a file name '1' and paste it another folder and also add folder name to file i.e., 'A1' I'm using the following code but its not working

for i in CC110033; do cp /dataslave2/shyamchand/aamod_meg_maxfilt_00001/$i/rest/transdef_mf2pt2_rest_raw.fif /cblhome/vivek/Data/MEG_data_80sub/transdef_mf2pt2_rest_raw.fif; done
  • 1
    Could you please add a sample of your input file to the question, rather than explaining it? – Kusalananda Mar 6 at 8:15
  • @Kusalananda I tried writing another code, may be you get better idea with it. {for i in CC110033 CC110037 do cp /dataslave2/shyamchand/aamod_meg_maxfilt_00001/$i/rest/transdef_mf2pt2_rest_raw.fif /cblhome/vivek/Data/MEG_data_80sub/$i_transdef_mf2pt2_rest_raw.fif done} – Vivek Sharma Mar 6 at 11:18
  • Clarifications to the question should be added to the question, not in comments. – Kusalananda Mar 6 at 11:20
0

To answer this I am assuming that CC110033 is the text file.

By using for i in CC110033 is pointless. The only thing you will get is a variable named $i which content is CC110033. You should choose a different loop structure. Like while read i; do .... done < CC110033

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.