I've seen several topics about approching subject. But I can't find the solution by myself.
I'm very new to shell and coding in general.
My goal is to detect blank image files in a given folder and delete those files.
Here's what I have so far (found in the forum) :
Code: Select all
for file in D:/00_TAKROG/ATLAS_UNITS_AND_DOODADS_TEMPORARY/*.png; do
convert "$file" -threshold X% -format "%[fx:mean==1?1:0]" info:
done
Code: Select all
for file in D:/00_TAKROG/ATLAS_UNITS_AND_DOODADS_TEMPORARY/*.png; do
convert "$file" -threshold X% -format "%[fx:mean==1?1:0]" info:
if [ ??? = "0" ]; then
echo "$file seems to be blank - removing it..."
rm "$file"
fi
done
Any help is welcome !
EDIT
I also found this solution :
Code: Select all
for file in D:/00_TAKROG/ATLAS_UNITS_AND_DOODADS_TEMPORARY/*.png; do
histogram=`convert "$file" -threshold 50% -format %c histogram:info:-`
white=`echo "${histogram}" | grep "white" | sed -n 's/^ *\(.*\):.*$/\1/p'`
black=`echo "${histogram}" | grep "black" | sed -n 's/^ *\(.*\):.*$/\1/p'`
blank=`echo "scale=4; ${black}/${white} < 0.005" | bc`
if [ "${blank}" == "1" ]; then
echo "$file seems to be blank - removing it..."
rm "$file"
fi
done
Code: Select all
bash: bc: command not found
Thanks
Arko