Bash to tell download where specific files are stored

The bash below will download all the files in download to /home/Desktop/folder . That works great, but within /home/Desktop/folder there are several folders bam , other , and vcf , is there a way to specify by extention in the download file where to download it to?

For example, all .pdf and .zip are downloaded to /home/Desktop/folder/other , all .bam are downloaded to /home/Desktop/folder/bam , and all .pdf.gz are downloaded to /home/Desktop/folder/vcf . Thank you :).

download

file1.pdf
file2.pdf
coverage(1).zip
coverage(2).zip
001__96.bam
002_96.bam
005.vcf.gz
006.vcf.gz
while read new; do
         echo $new
aria2c -x 4 -l log.txt -c -d /home/Desktop/folder --use-head=true --http-user "<user."  --http-passwd <password> xxx://www.example.com/folder/"$new"
done < /home/download

How about:

while read new; do

         case "$new" in
         *.pdf) DEST="/home/desktop/folder/other" ;;
         *.zip) DEST="/home/desktop/folder/other" ;;
         *.bam) DEST="/home/desktop/folder/bam" ;;
         *.pdf.gz) DEST="/home/desktop/folder/vcf" ;;
         *) DEST="/home/desktop/folder" ;;
         esac

        # If folder doesn't exist, make it
        [ -d "$DEST" ] || mkdir -p "$DEST"

        echo "$new => $DEST"

        aria2c -x 4 -l log.txt -c -d "$DEST" --use-head=true --http-user "<user."  --http-passwd <password> xxx://www.example.com/folder/"$new"
done < /home/download
1 Like

Thank you very much :).