Finding bad JPEGs with Xorg hacks in Ubuntu

So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely). qiv will spit out the following to STDERR when it finds one: Premature end of JPEG file So, this is nice, except it’s entirely unscriptable. The solution I found was using the following script to the display the images in sequence: perl -e ‘for(glob(“*.png *.jpg”)){$output = `qiv “$_” 2>&1;`; if($output =~ /Premature/){print $_, “\n”;}}’ All this does is mix STDERR [...]