<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
function delete_files($dir)
{
$handle = opendir($dir);
$cnt = 0;
$timeout = time()-60*60*24*2;
while(false !== ($file = readdir( $handle ))) {
$absfile = $dir . $file;
if(is_dir($absfile)) continue;
$mtime = filemtime($absfile); // ggf. filectime() statt filemtime() verwenden
printf("%s: mtime = %s, timeout = %s\n", $absfile, strftime("%Y-%m-%d,%H:%M:%S",$mtime), strftime("%Y-%m-%d,%H:%M:%S",$timeout));
if($timeout > $mtime) {
unlink( $absfile );
printf("%s geloescht\n", $absfile);
$cnt++;
}
}
closedir($handle);
echo 'Anzahl: ' . $cnt;
}
delete_files('/FI9805W_xxxE61FFCC/');
delete_files('/verzeichnis_2/');
delete_files('/verzeichnis_3/');