Download multiple files simultaneously (parallel) with custom filenames

octosquidopus picture octosquidopus · Nov 23, 2013 · Viewed 17.2k times · Source

In a bash script, I am trying to download multiple files in parallel, with custom filenames using a single command (no loops).

I tried using aria2c:

aria2c -j2 URL1 URL2                # BAD: outputs to a single file

aria2c -j2 -Z URL1 -o 1 URL2 -o 2   # BAD: filenames taken from link (-o is ignored)

The second one ignores the output filename because, quoting the aria2c manpage:

In Metalink or BitTorrent download you cannot specify file name. The file name specified here is only used when the URIs fed to aria2 are done by command line without --input-file, --force-sequential option. For example:

$ aria2c -o myfile.zip "http://example1.com/file.zip" "http://example2.com/file.zip"

This is what I want to avoid:

aria2c URL1 -o 1 &
aria2c URL2 -o 2 &
aria2c URL3 -o 3                     # BAD: slow and ugly, because aria2c is called thrice

Any suggestions?

Answer

ArtemB picture ArtemB · Nov 23, 2013

Aria2c supports getting URIs from a file.

Try writing your file names into the file and then running "aria2c -i uri-list.txt" or write them to stdout and pipe them to "aria2c -i -"