When I return from a trip (Hong Kong and Firenze in 2016), I'll have anywhere from 1000 to 2500 photos. There's a long process that follows - selection, editing, building HTML pages, culling. After the Florence trip I did the selection, but only a part of the editing. And I decided to be clever, saving a number of the edited images at lower quality - to save space because they were just for web display. But I save my edited images and use them for printing occasionally. And now I have a bunch of poorer quality images mixed in with my properly edited photos. But I didn't know which ones ...
Have I mentioned how much I love the Unix command line? It took me about five minutes of googling and writing to produce this:
#!/bin/bash
#
# Each verbose call to "identify" takes ~2.8 seconds. This is a SLOW script.
for file in $(ls -Sr 2016-05-??/toedit/edited/*)
do
qual=$(identify -verbose "${file}" | grep Quality | awk '{ print $2 }')
filename="${file##*/}"
if [ ${qual} -lt 95 ]
then
echo "${qual} ${filename}"
fi
done
Output looks like this:
69 20160515.0721.GO.FZ1000.jpg 68 20160516.0009.GO.FZ1000.jpg 75 20160515.0841.GO.FZ1000.jpg 69 20160516.0088.GO.FZ1000.jpg 75 20160515.0933.GO.FZ1000.jpg 70 20160516.0147.GO.FZ1000.jpg 68 20160516.0008.GO.FZ1000.jpg 69 20160515.0858.GO.FZ1000.jpg 69 20160515.0915.GO.FZ1000.jpg 69 20160516.0237.GO.FZ1000.jpg 70 20160515.0815.GO.FZ1000.jpg ...
What you need to know:
- you need the
identify
command from the ImageMagick package identify
in -verbose mode is agonizingly slow ... go get a coffee while this runs- this script is not prettified or generalized: it searches my directory structure, not yours, and it doesn't bother to print the image name and quality if the quality is 95% or better
- I cropped the folder names off the full filename with
filename="${file##*/}"
because the filename still tells me what dated folder the file is in: this may not apply to you ls -Sr
could easily be justls
- I was initially searching by file size, but that's not needed here. I didn't remove it because I like it as a first step, unnecessary or not.