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:

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

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

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