Convert all .bam of a folder to .sam

Written on February 15, 2015

The following is the bash command I use to convert all the BAM files in a folder to SAM files using SAMtools:

for file in ./*.bam; do
    echo $file 
    ~/Software/samtools-0.1.19/samtools view -h $file > ${file/.bam/.sam}
done