I'd like to write script that would automatically delete files older than a week in a specific directory. How would I go about doing that?
TIA
well, probably 1) open directory 2) loop through it with to get the filenames 3) compare creation time of each file to current timestamp 4) delete if older than one week (one week in seconds: 606024*7) 5) close directory
functions:
www.php.net/opendir www.php.net/readdir www.php.net/filectime www.php.net/mktime or www.php.net/time www.php.net/unlink www.php.net/closedir
if you've got problems with any of these steps, please be more specific and post what you've got so far.
forgot to mention: in case you want the script to execute weekly without being called, search for "scheduler" or cron".
Thanks for the pointers. Good stuff! I'll be running the script on Win2K so I'll just use the Windows Task Scheduler to run the script daily - the directory gets a new file every day and I only want to keep the latest 7.