Link to home
Start Free TrialLog in
Avatar of zaki100
zaki100Flag for Saudi Arabia

asked on

Schedule delete for files older than

Hello,

I have a folder in windows 2008 server that has some log files generated every 5 minutes.

How can I make schedule auto delete for files older than 3 hours.

Thanks

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

you did not yet google around for that, did you :)
http://www.google.lu/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=LZ8&q=vbscript+delete+files+older+than+x+hours&btnG=Search

anyhow, you need 2 parts:
? create a vbscript (easiest for me, at least), that deletes files older than X in a certain folder (+ subfolders, if needed)
? create a windows scheduled task to run that vbscript file (cscript yourscript.vbs)

Avatar of zaki100

ASKER

Thank you for your help

I have tried some of them but it deletes all files in a folder regardless file date time.

I need a direct tested answer using bat file

Reagrds

Zaki
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the matching .bat file contains this:

cscript d:\backupSQL\delete_old_files.vbs

Open in new window

Avatar of zaki100

ASKER

Thank you for your help

I will try and let you know.

Regards

Zaki