More shell magic: find orphan images

Ok, ok. So lets say you are using wordpress and want to find all the deprecated images in your theme’s image directory. Because I’m a madcap party animal, I’d say you could do something like this:

#!/bin/bash
for i in *.*; do
cd ..
RES=`grep -lIrc "$i" * | grep -v ":0" -`
if test -n "$RES"; then
echo "$i good, $RES";
else
echo "$i deprecated";
fi


#echo "move $i deprecated";
cd images/
done

fancy right? That’s how I get down for Saturday night.