views:

765

answers:

2

I have a shared disk that I would like to clean up once per week using a scheduled task of some sort. I would like to use a batch script so that the system admins can easily modify it or reuse it on other directories when needed.

The directory has files with multiple file extensions but the ones that need to be deleted end in .bkf and must be over 2 weeks old.

Does anyone have a batch script solution for this windows server (not sure which version)?

+1  A: 

If you have PowerShell (or can install it), check out this link: http://thepowershellguy.com/blogs/posh/archive/2007/12/13/hey-powershell-guy-how-can-i-delete-files-that-are-a-specified-number-of-hours-old.aspx

Austin Salonen
I can't unfortunately. Windows batch is all.
Joe Philllips
I think it's installed by default in Windows Server 2008. You might want to work with your sysadmins to see if it can be installed. MS is pushing it to be the server maintenance tool (a lot 2008 commands are built on PowerShell).
Austin Salonen
That link is dead.
Bill the Lizard
A: 

have you looked into forfiles.exe?

http://blog.stevienova.com/2007/02/27/forfiles-delete-files-older-than-x-amount-of-days/

phill