by Ken Task.
Thanks for sharing back.
Suggest installing moosh - a command line utility for Moodle.
It has a couple of commands related to files. Since you've done some massive work, one of moosh commands looks for orphaned files and diff's in metadata of mdl_files with actual presence of files in moodledata/filedir/
'SoS', Ken