I need to concatenate files based upon the name of the subdirectory they are in. The subdirectories sometimes have duplicates and sometimes don't. The file structure looks like this:
It is the 3 number prefix and the R-number that matters, and the concat should be done on matching R#'s, with the S-number being variable.
- No concatenation would need to be done to files in dir 633
- All 3 R1 files in the 739 dirs would need to be concatenated in order (739 first, 739(1)...)
- The output would need to go into a subdir of the subdir (/RootDir/739/739/*)
- In the end, each final output dir would have an concatenated R1 file and an R2 file.
I would greatly appreciate any help in the right direction. Also note that .fastq files are simply ASCII txt files.
edit: I saw this somewhat related post, but have had no success in using the code there due to the multiple matching folders issue.
edit2: Neither of these solutions are working for me. I am slowly combining ideas both have given me and will post my eventual solution here.