jmk
jmk

Reputation: 45

How to download multiple files using wget in linux and save them with custom name for each downloaded file

How to download multiple files using wget. Lets say i have a urls.txt containing several urls and i want to save them automatically with a custom filename for each file. How to do this?

I tried downloading 1 by 1 with this format "wget -c url1 -O filename1" successfully and now i want to try do batch download.

Upvotes: 1

Views: 4690

Answers (2)

Daweo
Daweo

Reputation: 36370

You might take look at xargs command, you would need to prepare file with arguments for each wget call, lets say it is named download.txt and

-O file1.html https://www.example.com
-O file2.html https://www.duckduckgo.com

and then use it as follows

cat download.txt | xargs wget -c

which is equivalent to doing

wget -c -O file1.html https://www.example.com
wget -c -O file2.html https://www.duckduckgo.com

Upvotes: 2

Max888
Max888

Reputation: 142

Add the input file and a loop:

for i in `cat urls.txt`; do wget $i -O filename-$i; done

Upvotes: 1

Related Questions