'Ubuntu - listing and deleting files by filtering from the list

I have approx. 1000 files in a folder and a mysql table has approx 200 rows which contains filenames. I need to delete 800 files which don't exist in my database table.

files>

/var/www/project/uploads/file1.ext and so on

MySQL table myuploads

id, title, file_name
1, File 1, file1.ext

I was thinking if I could download a csv file containing names of these files from the table and then filter against these to delete?

Do I need to write a bash script for it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source