I have a file storage directory used together with a MySQL DB.
Some of the files in the directory are orphaned (i.e. created by mistake, deleted in the DB but not on disk, otherwise not used).
I was able to generate list of such files without file extension but now what's the best way to move them out of the storage directory. The problem is that the storage is multi-level, so I have to find each file first somehow.
Sample of the orphan list content (200K lines in total):
10218
10219
10220
10221
10370
10371
10372
10373
10374
Directory structure (example):
If you wonder how I ended up with such a file:
- first, saved list of files in directory recursively to one file per https://stackoverflow.com/a/5456136/505984
- secondly, dumped DB table id's to another file with MySQL CLI (because each filename without the extension matches the DB record ID)
- diff'ed the two files as advised here: https://stackoverflow.com/a/25407317/505984