User:McZusatz/SuperSimpleMWdownload.sh

I, the copyright holder of this work, hereby publish it under the following license:
Beerware License The file is licenced under Revision 42 of the Beerware Licence.

I wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.

#!/bin/sh

#//
#// Input: files.txt (in pwd) including all files to download.
#//        * They need "File:" as prefix
#//        * Only one file per line
#//

#//
#// Output: All downloaded files are put in (pwd)/FileDownloads/*
#//

cat files.txt | while read file ; do
    curl --silent -G --data "action=query" --data "prop=imageinfo" --data "format=xml" --data "iiprop=url" --data-urlencode "titles=${file}" http://commons.wikimedia.org/w/api.php  | sed 's/.*url="http:\/\/upload/http:\/\/upload/g' | sed 's/".*//g' | wget --restrict-file-names=nocontrol --limit-rate=600K -P FileDownloads -i -
done