function deleteMissingLocalFileThumbnails() { printfnq("Removing all local File_thumbnail entries without existing files..."); $thumbs = new File_thumbnail(); $thumbs->whereAdd('filename IS NOT NULL'); // only fill in names where they're missing // Checking if there were any File_thumbnail entries without filename if ($thumbs->find()) { while ($thumbs->fetch()) { try { $thumbs->getPath(); } catch (FileNotFoundException $e) { $thumbs->delete(); } } } printfnq("DONE.\n"); }