This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to convert folder containing .fna.gz to normal files

How to convert .fna.gz files to .fna in a folder?

I would also like to convert all .fna to .fasta.

Thanks in advance

sequencing fasta
$ parallel --dry-run 'gzip -d {} > {= s:\.[^.]+$::;s:\.[^.]+$::; =}.fasta' ::: *.fna.gz

You can do it in two simple steps:

 1. rename -n 's/fna/fasta/' *.fna.gz  ## remove n option after checking the before and after output names
 2. gzip *.fasta.gz

2 answers

I hope this will work.

# Rename all *.fna to *.fasta
for f in *.fna; do 
    mv -- "$f" "${f%.fna}.fasta"
done

Or you can try

find . -name '*.fna' -exec rename 's/\.fna$/.fasta/' \{} \;

HI there, Thanks a lot, It worked. Dinesh

Go to the directory and follow the command..:)

find . -name ".fna.gz" |xargs -n 1 gunzip

HI there, Thanks. I would like to rename all files ending with .fna to .fasta. How to do that ? Regards, Dinesh

Log in to answer this question.