Making a module for this is on my To-Do-One-Day list. It's fairly tricky/risky problem - for each file you have to ask:
- Is the file referenced from any HTMLText instances?
- Does the file belong to any has_one relationships?
- Does the file belong to any has_many relationships?
- Does the file belong to any many_many relationships?
- If a folder - is it empty?
- Is the file URL referenced externally, e.g. on a separate website or inside a PDF? (In this case it should be marked as Protected somehow)
I have a task I use on one site that can do some of this but it doesn't support has_many or many_many at this stage.
Thinking the eventual module will generate a list of unused files that need to be reviewed, but make it quick to mark all or many for deletion, and also allow you to mark individual files as 'protected' so they're not picked out as candidates for deletion in future reports.
If anyone else is interested in this module idea leave a note and if there's lots of interest I might work on it sooner. I'll update this post if and when it's available. Even better if someone else builds it (or already has) and leaves a link here ;)