Created
September 4, 2017 16:04
-
-
Save robsonsobral/1672f9c4734f12459bc2546c2ae5d268 to your computer and use it in GitHub Desktop.
Delete unused image files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ] | |
then | |
echo "Please supply paths to search under" | |
exit 1 | |
fi | |
IMG_PATH=$1 | |
HTML_AND_CSS_PATH=$2 | |
find "$IMG_PATH" -name *.jpg > /tmp/patterns | |
find "$IMG_PATH" -name *.png >> /tmp/patterns | |
find "$IMG_PATH" -name *.gif >> /tmp/patterns | |
find "$IMG_PATH" -name *.svg >> /tmp/patterns | |
for p in $(cat /tmp/patterns); do | |
f=$(basename $p); | |
grep -R $f "$HTML_AND_CSS_PATH" > /dev/null || echo $p; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment