I need some help. I want to rename very many files with unique filenames using bash. I want to keep part of the original filename.
For example:
current file name | new file name |
---|---|
F1.R23.fastq.gz | 10_1.F1.R23.fastq.gz |
F2.R7.fastq.gz | empty_3_1.F2.R7.fastq.gz |
F32.R3.fastq.gz | 63_3.F32.R3.fastq.gz |
F5.R7.fastq.gz | Blank_3.F5.R7.fastq.gz |
F2.R2.fastq.gz | N5_1.F2.R2.fastq.gz |
What I have, is a file containing a column with the original names, and a column containing what I want to add to the names. Like so:
file | sample |
---|---|
F1.R23.fastq.gz | 10_1 |
F2.R7.fastq.gz | empty_3_1 |
F32.R3.fastq.gz | 63_3 |
F5.R7.fastq.gz | Blank_3 |
F2.R2.fastq.gz | N5_1 |
I would really appreciate if anybody has a way of doing this. I have potentially thousands of files to rename, some with complicated names and in a random order, and so it’s not really feasible to do this by hand.
Thank you!