Have a requirement for a simple PHP file management script.
At present I have a directory of images that match a stock list - when the stock list (a MySQL database) is updated, we have no mechanism to remove the old images.
The image names either match exactly the registration of the stock (e.g. [login to view URL]) or have a preceding digit (e.g. [login to view URL]).
The script would need to run through the existing stock list and delete all images from the directory that don't have a matching record in the database. It should leave images that do have a matching record. It should not delete non-jpg files (e.g. PHP files, .htaccess file, HTML files, etc.)
The script will be manually run, there is no need to set-up a cron job to run this automatically.
All images are in JPG format. The server supports both PHP 4 and 5, MySQL version 5.0.81.