This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to rename multiple file name

Hi I want to rename multiple file:

Old File Name is like this:

 SRR4104645_1.fastq          SRR4104648_1.fastq

SRR4104645_2.fastq           SRR4104648_2.fastq

New File name should be like this:

SRR4104645_R1.fastq                          SRR4104648_R1.fastq

SRR4104645_R2.fastq                         SRR4104648_R2.fastq
rna-seq

Do you want to add R in all the sample names?

Yes arup, I only need to add R...

2 answers

Try this

rename '_' '_R' *fastq

P.S. I didn't test this but it should work.

EDIT: Check this. There seem to be different versions of rename command. I use the above version. Another one seems to be following sed kind of syntax.

Hi,

this pure bash solution works too:

for i in *1.fastq; do mv $i ${i%_1.fastq}_R1.fastq; done && for i in *2.fastq; do mv $i ${i%_2.fastq}_R2.fastq; done

Just copy and paste to your terminal and it should rename all file.

for file in *.fastq; do mv -v $file ${file/_/_R}; done should be sufficient.

Log in to answer this question.