

curl http://commons.wikimedia.org/wiki/Sovereign-state_flags | egrep -o 'src="//upload.wikimedia.org/wikipedia/commons/thumb/\w+/\w+/Flag_of_[^/]+.svg' z | sed 's|src="//||' | sed 's|/thumb||' > flag_files.txt
echo http://upload.wikimedia.org/wikipedia/commons/e/ef/Flag_of_Hawaii.svg >> flag_files.txt

for i in `cat flag_files.txt`; do curl $i -O; done

for i in *.svg; do mv $i `echo $i | tr '[:upper:]' '[:lower:]' | sed 's/%..//g' | sed 's/[^a-z0-9_]/_/g' `; done

for i in *.svg *.png; do convert $i -resize 66x66 ../flags_png/${i/svg/png}; done