Reputation: 1523
aria2c
has an event hook feature that runs a given script when an event occurs. Using the --on-download-complete
param for example, is there a way to change the output file's name to its download URL? Now there may be a way to use -o
somehow, but I don't think it will effective when handling multiple downloads. Here's an example of what I'd be using as the base command:
aria2c -i <urls> --optimize-concurrent-downloads true
Upvotes: 2
Views: 3070
Reputation: 27340
is there a way to change the output file's name to its download URL
No, because file URLs contain the character /
which is the only character that cannot be part of a filename in Linux, since it is used a as separator for paths like path/to/dir/
.
Windows uses \
as a delimiter, but still forbids to use /
inside a filename.
However, you can change the /
to something different like |
. You can manually specify the output name for each input URL inside your input file like so:
domain.tld/abc/xyz/file1
out=domain.tld|abc|xyz|file1
something.sth/abc/xyz/file2
out=something.sth|abc|xyz|file2
...
To generate and use a file like this, use
awk '{print; gsub("/","|"); print " out="$0}' fileOfUrls | aria2c -i-
I thought that aria2c already names the files like they are named in the URL. If that doesn't work, generate an input file accordingly:
sed 's|[^/]*$|&\n out=&|' fileOfUrls | aria2c -i-
Upvotes: 2