Thursday, 18 June 2009

Delete Files Older than Some Days

Delete Files older than 5 days: Here in this we are deleting files older than 5 days with .bak extension from the directive D:\delete: Tested in Windows 2003 Server.


C:\Documents and Settings\Administrator>forfiles /P D:\DELETE\ /S /D -5 /M *.bak /C "cmd /C del @path /Q"



Before execution of the script, you may see file temp.bak older than 5 days. The script execution date is 18th June 2009.

After execution, the file temp.bak was deleted. But still the file backup.bak exists. Because the file backup.bak was created on the day of the execution. That 18th June 2009. Therefore, this demo proves that this script works for deleting files older than some days.

No comments:

Post a Comment