I need to write rb script that will recursively search a directory for
all files of particular types - say *.jpg, *.gif and *.png files. Then
I need to re-search the same directory structure identifying which of
these image files are not referenced anywhere in *.htm, *.html or
*.php files.

In a nutshell I need to find all files of a particular type that are
not referenced in the source of a second set of files. This has to
work recursively and be general purpose enough to be easily modified
for different but similar problems. Anyone know how to approach this
task? I would like to have some arguments like the following:

look_for=%w(jpg gif png)
look_in=%w(htm html php)

I am cleaning up a big pile of unstructured files for a web site and I
anticipate having to perform dozens of small tasks like this to
identify unreferenced files, backup copies, dead code. Maybe there is
a gem for something like this. Thanks in advance for any help.