Last active
January 9, 2017 11:25
-
-
Save esaborit4code/5868140 to your computer and use it in GitHub Desktop.
Bash script to find unused images within a project's folder.
Based on Volomike's script at http://stackoverflow.com/a/8174681
This file contains 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 | |
# Based on Volomike's script at http://stackoverflow.com/a/8174681 | |
MYPATH=$1 | |
ALL_IMAGES=$MYPATH/all_images | |
UNUSED_IMAGES=$MYPATH/unused_images | |
echo "" > $ALL_IMAGES | |
for format in jpg jpeg png gif; do | |
echo "Search for $format images started" | |
find "$MYPATH" -name *.$format -exec basename {} \; >> $ALL_IMAGES; | |
echo "Search for $format images finished" | |
done | |
echo "" > $UNUSED_IMAGES | |
for image in $(cat $ALL_IMAGES); do | |
echo "Search for usages of $image started" | |
grep -R $image "$MYPATH" > /dev/null || echo $image >> $UNUSED_IMAGES | |
echo "Search for usages of $image finished" | |
done | |
echo "All finished!!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment