hi i have about 10.000 files in my hard drive i want to delete the files e.g. from 1 jan 2007 to 1 mar 2007 i dont have a mysql database for these files all files in a folder how i can do that?
You actually want this to do with PHP? "On your harddrive" sounds more like you have the files on your computer. Use the advanced Windows search function. It'll do the job.
you need to write a php program which can easily do but before you even try that you should have a proper bckup of site. it will be only 25-30 line php program i guess Regards Alex
yeah i want it with php but i dont know how to write i dont have enough experince so if you can help me its ok
$get_list = mysql_query("SELECT * FROM `files` WHERE `datefield` > '01-01-2007 00:00:00' AND `datefield` < '03-01-2007 00:00:00'"); while($each = mysql_fetch_assoc($get_list){ unlink($each['filelocationfield']); $remove_file = mysql_query("DELETE FROM `files` WHERE `fileidfield` = '$each[fileidfield]'"); } PHP: Test before using (not tested). Peace,
Oops, sorry didn't read the question right. Use fileatime to get date modified: http://us2.php.net/manual/en/function.fileatime.php and then just an if else statement like the above to check if match, then remove. Peace,
Bahaa just use ur OS , if you have windows or Linux there is ways to display files and then just delete them ..
If So use those functions : ls -lrt // List files by date. find /path/to/files* -mtime +365 -exec rm {} \; // removes files older than 365 days i dont take any responsability for testing those lol , test at your own risk found this also find /path/to/files* -mtime +365 -exec ls -a {} \; // you can test this to see the files that will get deleted . just search google for : delete files based on date + linux
You can do this very easily through most ftp programs, for example I use cuteFtp, connect to your server, open the folder you want to delete the old files from, select from the listing tabs "Modified" this will place your 10'000 list of files in order of date. Then all you have to do is select a starting point(date), hold the SHIFT button on your key, use the scroll bar and drag that down to the last date you want to delete, click that date, all above files will be highlighted, then simple right click and Delete.