8

How do you download a series of files with wget like so:

http://www.example.com/index.php?file=1
http://www.example.com/index.php?file=2
http://www.example.com/index.php?file=3
...
http://www.example.com/index.php?file=500
Stall
  • 183

2 Answers2

19

wget supports downloading more than a file with a single command. This means that you can take advantage of your shell features like so:

wget http://www.example.com/index.php?file={1..500}

If your URLs are in a file (one URL per line) or on standard input, you can also use wget's -i option.

  • 2
    If the numbers have padding, you can also do it this way: wget http://www.example.com/index.php?file={001..500} – Jeff Olson Jan 22 '17 at 03:12
4

Place all the urls in a file, one url per line. Let's call it file.txt.

Then place the code inside another file:

#!/bin/bash
while read url; do
   wget "$url"
done < file.txt

save the file at the same directory file.txt and execute it through a terminal.

If you would like to download the files simultaneously, then simply add an & after the wget "$url" command (at the same line)

hytromo
  • 4,904