Purge a Directory in Windows automatically
Sometimes there is no easy way to tidy up a directory in windows. In Linux its as easy as using tmpwatch or find and rm.
Luckily there is a handy tool in the Windows Resource kit called "forfiles" which can do this for you with a one liner batch file.
Note: bloody microsoft changed the switches between Windows 2000 and 2003 so its slightly different.
Windows 2000Download forfiles for win2k from
herePlace the executable somewhere in your path and create a batch file. An example is below which deletes files with extensions *.ctf in drive f and g older than 10 days. (ofcourse run forfiles /? for help).
Be wary of the syntax, it changed between win2k and win2003, case and no spaces are important in windows 2000 version.
-p = path, -m=search filter, -d=days older than X, -c=command to run
forfiles -pf: -m*.ctf -d-10 -c"CMD /c del @FILE : date >= 10 days"
forfiles -pg: -m*.ctf -d-10 -c"CMD /c del @FILE : date >= 10 days"
Windows 2003forfiles should be standard in windows 2003. The example below deletes all files in the specifed directory older than 7 days.
/p=path, /s=recurse subdirectories, -m=search filter, -d=days older than X, -c=command to run
forfiles /p P:Nexusdsxmlspool /s /m *.* /d -7 /c "cmd /c del @file : date >= 7 days"
other Windows Related Tips...