Skip to content

Instantly share code, notes, and snippets.

@innermond
Created January 24, 2018 11:31
Show Gist options
  • Save innermond/9046ff6710f47dd50c1e3c8fa77f7b63 to your computer and use it in GitHub Desktop.
Save innermond/9046ff6710f47dd50c1e3c8fa77f7b63 to your computer and use it in GitHub Desktop.
Remove files that are not valid jpg
#!/bin/bash
# this script should be run by command: find . -type d -exec ./.remove-wrong-images {} \;
if [ ! -d "$1" ]; then
echo "need a directory"
exit 1
fi
cd "$1"
for f in *.jpg; do
[ -f "$f" ] || continue
identify -- "$f" > /dev/null
if [ $? -eq 1 ]; then
echo "removing: $f"
rm -- "$f"
fi
done
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment