Download Many Images in One Line ::

January 26, 2013 at 2:50 pm EST

I wanted to download all of these wallpapers because quite frankly, it’s an awesome car. The fact of the matter is though, 45 images is quite a few. I used this one liner in Ruby to download all of them using wget:

1.upto(45) { |x| `wget{“%02d” % x}-mclaren-p1-paris.jpg -O #{“%02d” % x}-mclaren-p1.jpg` }

Easy huh? ┬áThe “%02d” % x is used to pad ‘x’ with the correct number of 0’s. ┬áThis sort of thing can be applied to a lot of other pages given there is some kind of simple pattern like there was in this one.

No Comments