I have thousands of folders with files inside them and I want to copy some of them in another directory. I have a .csv
file with two columns with part of the folder name (the folder contain one string value or another, not both).
- Example of folder names:
PLASMA_32150129_B5/ PLASMA_AAA3891784_B3/ ...
- The CSV file has no header and the fields are separated by
,
:32150129,AAA0616938 32140203,AAA3891784 32140204,AAA0617237 32140205,AAA0617261 32140206,AAA0617285 ...
- I found this little script as a starting point:
while IFS=, read -r file rest do find /path/to/Main_directory -type d -name "${file}" -exec cp '{}' /path/to/New_directory/ \; done < mylist.csv
Now I need to specify that
- the csv values are just a pattern (like
*_32150129 _*
), and - I want to try pattern in the first column first, and if that doesn't generate a match, try with the other one.
Is this possible?
Thank you!
32150129,AAA0616938
, can you have a directory calledPLASMA_32150129_B5
and another calledPLASMA_AAA0616938_B5
? Or can we be sure that there will always only be one hit?mylist.csv
? What format does that have?