Using curl to download files numbered sequentially   no comments

Posted at 4:29 am in Console One-Liners

Ever had the dilemma of downloading files numbered sequencially without clicking each one of them and saving them? Everybody knows how robotic this task is especially if you have more than a handful of files to download. Well yes you can use download managers and browser plugins (Firefox’s DownloadThemAll!) but what if the file’s link is deeply embedded in the html file (eg: a photo gallery)?

If you have access to some type of unix console (linux, mac, windows via cygwin), you have the option to use the venerable wget. But using wget we have to make a script to automatically generate the sequencial filenames. Possible but, too much work.

Luckily we have curl.

$ curl -O http://some.website.com/gallery/babypictures-[001-100].jpg

Let me explain the command above. ‘-O’ (that’s a capital O) tells curl to download and save the file using it’s remote name. That little bracket trick in the filename (babypictures-[001-100].jpg) tells curl that the files are sequentially numbered with leading zeroes. You can do away with the leading zeroes if the files you need don’t use them.

That’s all :)

Written by admin on April 12th, 2008

Tagged with , , ,

Leave a Reply