Skip to content

Instantly share code, notes, and snippets.

@chip
Created December 23, 2013 19:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chip/8102870 to your computer and use it in GitHub Desktop.
Save chip/8102870 to your computer and use it in GitHub Desktop.
This helps me find unused images in a Rails project. The echo statement never executes, so there's a glitch, but the output was helpful nonetheless. I'll try to improve later.
#!/bin/sh
PROJECT="" # Fill this in
IMAGES="$PROJECT/app/assets/images"
VIEWS="$PROJECT/app/views"
CSS="$PROJECT/app/assets/stylesheets"
for image in `find $IMAGES -type f`
do
name=`basename $image`
echo "Searching for $name [originally $image]"
if ! ag $name $VIEWS $CSS; then
echo "$image is not referenced"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment