How to rename multiple file name
2
0
Entering edit mode
6.9 years ago
Bioinfonext ▴ 470

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 • 5.2k views
ADD COMMENT
2
Entering edit mode
6.9 years ago
venu 7.1k

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.

ADD COMMENT
0
Entering edit mode

Thanks, Its correct!

ADD REPLY
1
Entering edit mode
6.9 years ago
Paul ★ 1.5k

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.

ADD COMMENT
1
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1646 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6