linux - 并行下载 url 列表并重命名

标签 linux wget

我有一个以制表符分隔的 url 和目标文件名的列表,urls_to_download.txt,例如:

first_file.jpg\thttps://www.google.co.il/images/srpr/logo11w.png
/subdir_1/second_file.jpg\thttps://www.google.co.il/images/srpr/logo12w.png
...
last_file.jpg\thttps://www.google.co.il/images/srpr/logo99w.png

我想使用多个连接下载。

我可以这样做,例如:

cat urls_to_download.txt | xargs -n 1 -P 10 wget -nc

我的问题是,如何让文件具有我想要的新名称,以便输出目录具有:

first_file.jpg
/subdir1/second_file.jpg
...
last_file.jpg

最佳答案

我猜这样的东西应该适合你:

#!/bin/bash                                                                                                                                                                       
while read FILENAME URL; do
  wget -nc -O "$FILENAME" "$URL"
done <input.txt

其中 input.txt 是一个文件,其中包含制表符分隔的文件/url 对,每行一个。

关于linux - 并行下载 url 列表并重命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24731156/

相关文章:

linux - 如何使用touch命令在指定目录创建文件

linux - 错误 : You must install at least one postgresql-client-<version> package

linux - Linux下如何识别USB Storage "volume name"?

linux - 如何使用wget从 "wikimedia search result"下载图像?

php - wget下载队列脚本

C++,我如何在 html 代码中获取特定的字符串

linux - 进程卡在linux桌面

linux - Linux 的 Oracle JDK 链接是否断开?

python - 即使安装了 wget,也无法将其识别为命令

linux - 在 ThinkPad w550s Ubuntu 系统(Quadro K620M)上运行 CUDA