I have a directory with sub-directories. In the directories, there are a lot of images, crawled from the web.
How do I loop through every file and show those files which are not valid image files?
It should not be based on file extension.
I came up with this script:
find . -name '*.jpg' -o -name '*.jpeg' -o -name '*.gif' -o -name '*.png' | while read FILE; do
if ! identify "$FILE" &> /dev/null; then
echo "$FILE"
fi
done
But this is not working, because it outputs valide images, too.