I know there has been discussion around this topic - bulk deletion of legacy course files - and afaik there are no tools for this yet. I've referenced the following thread and tracker item:
I would like to try to do this by querying legacy files by user (where filearea=legacy) and grabbing the contenthash where I could then maybe remove the files via shell script. Once gone, I can delete the DB references in mdl_files and mld_files_reference.
Does anyone see a problem with this? I'm reluctant to do this without advice.