使用 aria2c,有没有办法在批量下载中使输出文件名与输入 URL 相同?
Using aria2c, is there a way to make the output filename the same as the input URL in a batch download?
aria2c
具有事件挂钩功能,可在事件发生时运行给定的脚本。例如,使用 --on-download-complete
参数,有没有办法将输出文件的名称更改为其下载 URL?现在可能有一种使用 -o
的方法,但我认为它在处理多个下载时不会有效。这是我将用作基本命令的示例:
aria2c -i <urls> --optimize-concurrent-downloads true
使用整个 URL 作为文件名
is there a way to change the output file's name to its download URL
否,因为文件 URLs 包含字符 /
,这是 Linux 中唯一不能作为文件名一部分的字符,因为它用作分隔符像 path/to/dir/
.
这样的路径
Windows 使用 \
作为分隔符,但仍然禁止在文件名中使用 /
。
但是,您可以将 /
更改为其他内容,例如 |
。您可以在输入文件中为每个输入 URL 手动指定输出名称,如下所示:
domain.tld/abc/xyz/file1
out=domain.tld|abc|xyz|file1
something.sth/abc/xyz/file2
out=something.sth|abc|xyz|file2
...
要生成和使用这样的文件,请使用
awk '{print; gsub("/","|"); print " out="[=11=]}' fileOfUrls | aria2c -i-
仅使用URL中的文件名作为文件名
我认为 aria2c 已经命名了文件,就像它们在 URL 中的命名一样。如果这不起作用,请相应地生成一个输入文件:
sed 's|[^/]*$|&\n out=&|' fileOfUrls | aria2c -i-
aria2c
具有事件挂钩功能,可在事件发生时运行给定的脚本。例如,使用 --on-download-complete
参数,有没有办法将输出文件的名称更改为其下载 URL?现在可能有一种使用 -o
的方法,但我认为它在处理多个下载时不会有效。这是我将用作基本命令的示例:
aria2c -i <urls> --optimize-concurrent-downloads true
使用整个 URL 作为文件名
is there a way to change the output file's name to its download URL
否,因为文件 URLs 包含字符 /
,这是 Linux 中唯一不能作为文件名一部分的字符,因为它用作分隔符像 path/to/dir/
.
这样的路径
Windows 使用 \
作为分隔符,但仍然禁止在文件名中使用 /
。
但是,您可以将 /
更改为其他内容,例如 |
。您可以在输入文件中为每个输入 URL 手动指定输出名称,如下所示:
domain.tld/abc/xyz/file1
out=domain.tld|abc|xyz|file1
something.sth/abc/xyz/file2
out=something.sth|abc|xyz|file2
...
要生成和使用这样的文件,请使用
awk '{print; gsub("/","|"); print " out="[=11=]}' fileOfUrls | aria2c -i-
仅使用URL中的文件名作为文件名
我认为 aria2c 已经命名了文件,就像它们在 URL 中的命名一样。如果这不起作用,请相应地生成一个输入文件:
sed 's|[^/]*$|&\n out=&|' fileOfUrls | aria2c -i-