Menu
Hi All,
I have the following code which I intend to run once or twice a week to delete old files from my web servers uploads folder.
[code=php]$dir = ‘../uploads’;
if (is_dir($dir)) $files = scandir($dir);
foreach ($files as $file) {
if ($file == ‘.’ || $file == ‘..’) continue;
if (fileatime($dir . ‘/’ . $file) < strtotime(‘-90 days’)) unlink($dir . ‘/’ . $file);
}
I am interested in getting the best performance possible from this script as there are many thousands of files in the uploads folder.
I this code the most efficient way of getting the job done?
—
Thanks,
dai.hop