for F in public/*/cover.jpg public/*/cover.png do echo Processing: $F B=$(echo $F | sed s/.jpg// | sed s/.png//) D=$(dirname $F) if [ $F -nt $D/thumbnail.png ] then PORTRAIT=$(convert $F -format '%[fx:w $D/thumbnail.jpg pngtopnm $B.1x.png | cjpeg -progressive -optimize -sample 1x1 -quality 95 > $B.1x.jpg pngtopnm $B.2x.png | cjpeg -progressive -optimize -sample 1x1 -quality 95 > $B.2x.jpg done