1

There is a gallery in the format:

http:\\DOMAIN\file0001.jpghttp:\\DOMAIN\file0543.jpg

How can I download them all using wget?

How can I make it wait 2 seconds between downloads?

i'm using bash ver 3.2.

1
  • 2
    FYI, URLs use forward slashes (http://domain/), never backslashes. Commented Sep 29, 2011 at 11:42

2 Answers 2

2

In bash:

for ((i=1; i<=500; i++)); do wget http://DOMAIN/file`printf "%04d" $i`.jpg; done

If you want to wait 2 seconds between downloads, add a sleep 2; before the done

2

Use ranges with {..}.

$ wget http://example.com/file{0001..0543}.jpg

The above answer works with zsh and bash version 4 and above. See the answer posted by @w00t if you're using an older version of bash (bash -version to check).

enter image description here

2
  • That doesn't keep the starting 0s
    – w00t
    Commented Sep 29, 2011 at 9:58
  • Cool, didn't know that. Now for the long wait until all bashes are v4 :-)
    – w00t
    Commented Sep 29, 2011 at 11:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .