Home > Back-end >  Download URLs from list and specify filename
Download URLs from list and specify filename

Time:09-16

I have a text file with the following format:

https://www.example.com/download/3r9uf3933i239.jpg,file1.jpg
https://www.example.com/download/fjf93j9f92022.jpg,file2.jpg
https://www.example.com/download/j929kd9d29f91.jpg,file3.jpg
https://www.example.com/download/asj20fdj9jkf7.jpg,file4.jpg

As you can see, each line contains the url and the filename seperated by a comma. How can I make wget download each file one by one and save it as the specified file name? I am using command line on linux.

CodePudding user response:

You can use something like:

while IFS=, read a b
 do wget $a -O $b
done <input_file

the trick is set IFS variable (which indicate the delimiter) and read two variables: a and b

  • Related