wget 指定目的地的文件列表

wget list of files with specified destination

我有一个包含一堆 url 的 .txt 文件(大约 2000)。 每行包含 url 制表符和本地目的地。像这样

http://www.example.com/file/1/2/3   d:\download\download.txt
...
...

有没有办法使用 wget 来自动化这个过程? 谢谢

如果您的文件 url 和目标文件由制表符分隔,您可以执行以下操作:

比方说,文件如下所示:

http://abcdef1.com  file1.txt
http://abcdef2.com  file2.txt
http://abcdef3.com  file3.txt
http://abcdef4.com  file4.txt
...

然后你可以使用下面的 bash 脚本(如果你是 bash shell):

 #!/bin/bash

while IFS= read  -r line
do
    if [[ ! -z $line ]]; then
        url=$(echo $line | cut -f1)
        dest=$(echo $line | cut -f2)
        wget $url -O "${dest}"
    fi
done <<(cat urls.txt)

如果您的 urls.txt 文件只有逐行分隔的 URL,您可以简单地使用

wget -i urls.txt