Lego2012
9/26/2016 - 9:55 PM

Find unused Images in Project

Find unused Images in Project

#!/bin/bash

if [ $# -eq 0 ]
  then
    echo "Please supply path to search under"
    exit 1
fi
MYPATH=$1

find "$MYPATH" -name *.jpg > /tmp/patterns
find "$MYPATH" -name *.png >> /tmp/patterns
find "$MYPATH" -name *.gif >> /tmp/patterns
find "$MYPATH" -name *.js >> /tmp/patterns
find "$MYPATH" -name *.php >> /tmp/patterns

for p in $(cat /tmp/patterns); do
    f=$(basename $p);
    grep -R $f "$MYPATH" > /dev/null || echo $p;
done