Reduce FASTA file name
2
0
Entering edit mode
8.8 years ago
Eva_Maria ▴ 190

I have more than 60000 fasta file and which having long name like

BA000031.2_ID=gene0_Name=VP0001_gbkey=Gene_gene=VP0001_gene_biotype=protein_coding.fasta
BA000031.2_ID=gene8_Name=VP0009_gbkey=Gene_gene=VP0009_gene_biotype=protein_coding.fasta

and I want to change like this

VP0001.fasta
VP0009.fasta

like this for all 60000 files how it possible

perl awk fasta genome • 1.5k views
ADD COMMENT
1
Entering edit mode
8.8 years ago

Use the rename command. Check man rename for available options (rename comes with perl and newer perls have more options).

ADD COMMENT
1
Entering edit mode
8.8 years ago
Jenez ▴ 540

I'm sure there's an elegant awk solution out there but here's my somewhat shitty loop for it. It assumes all files keep the same structure as the ones you've posted.

for f in *_coding.fasta; do new="$(echo $f | tr '=' '_' | cut -d '_' -f 5)"; mv $f $new.fasta; done
ADD COMMENT

Login before adding your answer.

Traffic: 2696 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