octosquidopus
octosquidopus

Reputation: 3713

Download multiple files simultaneously (parallel) with custom filenames

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?

Upvotes: 15

Views: 24506

Answers (2)

gulp79
gulp79

Reputation: 281

with -Z option:

-Z, --force-sequential[=true|false] Fetch URIs in the command-line sequentially and download each URI in a separate session, like the usual command-line download utilities.

so in your case:

aria2c -Z URL1 URL2 URL3 URL4  

Upvotes: 28

ArtemB
ArtemB

Reputation: 3632

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 -"

Upvotes: 21

Related Questions