for x in "$1"/*.jpg; do y=`echo "$x"|rev|cut -d '/' -f 1|rev` jpegtopnm "$x" | pnmscale -xysize 1024 768 | pnmtojpeg > __$y done