Skip to content

Instantly share code, notes, and snippets.

@jakelazaroff
Last active December 25, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakelazaroff/7007603 to your computer and use it in GitHub Desktop.
Save jakelazaroff/7007603 to your computer and use it in GitHub Desktop.
Removes all unused jpgs and pngs from a directory recursively.
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for i in `find . -name "*.png" -o -name "*.jpg"`; do
file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x`
result=`grep -r $file .`
if [ -z "$result" ]; then
git rm "$i"
fi
done
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment