Moodle’s file directory took a new approach with the release of Moodle 2.0, no longer did each course has a specific and identifiable folder in which files were uploaded into (Legacy Files) now each file is uploaded, assigned a sha1 hash and controlled by user permissions where the file can be displayed and who has the right to utilize it.
In the case that a teacher stops using a file in their course, they can choose to remove the link without deleting the file which could have long term effects on the size of your disk.
This utility, File Trash, creates a way for you to find and review files which have been uploaded to your Moodle site but no longer are connected to be displayed to users (orphaned files). It was created and is maintained by Barry Oosthuizen and is available for Moodle 2.5 and up (including 2.9).
According to the description,
The files in the Moodle data folder and backup folders are referenced in the “files” table in the database. If you view the folders themselves you will find the sha1 hash code under which the file has been saved and referenced in the database. If you have any orphaned files (files no longer referenced by the database but still present on your disk) it will be very difficult to find them. This utility enables you to immediately receive a list of orphaned files together with the file type and size. You can download the file to see what it is (the name is a sha1 hash so that won’t give you any clues). If you are happy to delete the file you can select it with the checkbox next to it’s description and click delete. You will be asked for confirmation before the file is finally deleted.
Download File Trash here: https://moodle.org/plugins/view/report_filetrash