User:McZusatz/SuperSimpleMWdownload.sh

From Wikimedia Commons, the free media repository
Jump to: navigation, search
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.


Dansk | Deutsch | English | Español | Français | Italiano | Македонски | മലയാളം | Русский | +/−

#!/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 -P FileDownloads -i -
done