Finding instances of file usage on pages from /files dir
steve02476 - March 19, 2009 - 15:13
My site has a few hundred files that have been uploaded into the files directory. I'd like to do some weeding of that /files directory.
For any particular file in the files directory, how can I find out if that file is being used on a particular page in Drupal, either as a "file attachment" or referenced by a download link in the text or an embedded image link?
Is there some magical module that will help with this? Thanks all!

I was able to come up with an
I was able to come up with an SQL snippet that will show me what nodes have ever mentioned a particular file:
SELECT DISTINCT `nid`FROM `node_revisions`
WHERE `body` LIKE '%filename_being_searched_for.jpg%'
But I think this shows me node ids where a past revision had a particular file linked within it. And it doesn't show me if a file in the files directory is attached to a particular node.
Any ideas?
Scanner Module
I just found the Search & Replace Scanner module http://drupal.org/project/scanner - it knows how to search for html strings AND it is happy to return only published nodes (not prior revisions).
_
You should be able to use views for this. There's a couple of different ways depending what module you use for file attachments. for example, if you use the core upload module you can make a node view and use the 'upload: has attached files' filter.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
I don't know how to use Views
I don't know how to use Views yet, although I have it installed. I guess this is a good learning opportunity for me! Thanks for the tip.