Skip to content

Instantly share code, notes, and snippets.

@trodemaster
Created January 9, 2014 00:13
Show Gist options
  • Save trodemaster/8327176 to your computer and use it in GitHub Desktop.
Save trodemaster/8327176 to your computer and use it in GitHub Desktop.
badpeg.sh sell script for validating jpeg files using imagemagick. Adds a hyphen to the end of the filename if the test fails.
#!/bin/sh
# rename bat jpg files
# usage with large number of files
# cd to the directory containing the images
## ls ./ | xargs badpeg.sh
for filename in "$@"
do
#lastPix=`convert $filename -format "%[pixel: u.p{699,465}]" info:`
#echo $lastPix
if [[ `convert $filename -format "%[pixel: u.p{699,465}]" info:` == fractal ]]
then
mv $filename $filename"-"
echo $filename is a bad jpeg
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment