Search This Blog

Tuesday, 16 October 2012

Windows forfiles

There's loads of reading out there for "forfiles" but here's a quick reference:

forfiles /p "c:\whatever\logs" /m *.log /d -7 /c "cmd /c del @path"

delete all .log files older than 7 days from c:\whatever\logs

/p - path to traverse
/m - mask
/d - number of days old
/c - command

@file - current filename
@path - fully qualified current filename

http://technet.microsoft.com/en-us/library/cc753551(v=ws.10).aspx

No comments:

Post a Comment