Home > OS >  How to download multiple files using wget in linux and save them with custom name for each downloade
How to download multiple files using wget in linux and save them with custom name for each downloade

Time:04-23

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.

CodePudding user response:

Add the input file and a loop:

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

CodePudding user response:

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
  • Related