Script to delete files on a Windows 7 or 2008 box

So recently I found myself needing to do some log management of some custom logs I was writing to disk. Put this guy in a .bat file and use task manager to keep things in check:

forfiles -p “c:\logs\nginx” -s  -m *.* -d  -1 /C “cmd /c del @PATH”

Two important things to watch out for. After the path CAN NOT include a backslash ‘\’ That will stop it from running. Second, after the -d is the number of days old that you want it to delete. 

Maybe next I’ll create a script to zip the logs and ship them off somewhere.