I’m writing a simple batch downloader for files, which have the format Y-m-d.pdf. I want to pass the dates (from, to) as a parameter, e.g.:
./download.sh 2012-01-01 2012-01-31
That should download all files for January 2012.
Here’s what I got so far:
#!/bin/bash
for i in {0..9}
do
curl -u user:pw http://server/path/somescript.pl?date=`date -v-"$i"d +%Y-%m-%d` -o `date -v-"$i"d +%Y-%m-%d`.pdf
done
This downloads the ten most recent files.
EDIT: How can I iterate over a range of dates instead? Something like:
for d in {2012-01-01..2012-03-31}
I was hoping for a built-in feature, otherwise I would need to take care of the number of days in each month (not to forget leap years) myself.
The following shows the basic idea, you have to put the
curlstuff in for yourself:If you call it: