I have over 500 paired fastq files. They have been received from a source where the Sample Identifier (S1, S2, S3) is no longer in the file names. I need to add a Sample Identifier to my paired file names for processing using QIIME2.
Here are some example file names:
Tube211-16S_L001_R1_001.fastq
Tube211-16S_L001_R2_001.fastq
Tube212-16S_L001_R1_001.fastq
Tube212-16S_L001_R2_001.fastq
Tube213-16S_L001_R1_001.fastq
Tube213-16S_L001_R2_001.fastq
I would like to add sequential Sample Identifiers to these so that they would look like this when finished:
Tube211-16S_S1_L001_R1_001.fastq
Tube211-16S_S1_L001_R2_001.fastq
Tube212-16S_S2_L001_R1_001.fastq
Tube212-16S_S2_L001_R2_001.fastq
Tube213-16S_S3_L001_R1_001.fastq
Tube213-16S_S3_L001_R2_001.fastq
I have tried to get this working however what it does is just add S1 to all of the R1 file names:
for((k=1;k<=516;k++)); do for i in *.fastq; do mv "$i" "`echo $i | sed "s/_16S_L001_R1/-16S_S${k}_L001_R1/"`"; done; done
I need to add the same Sample Identifier to the R1 and R2 paired file names.
How can this be done?
.