Monday, 7 September 2009

ForFiles command - windows server 2008

forfiles command is quite useful as it has the /d switch (date) which can be set to less than 30 days (-30) or more. The /m is a mask that you can set to the extension of files you wish to find to save you from doing a *.*. Then it will do the command in “ “ for each file that meets the criteria.


This deletes any files in c:\a:\test and its subdirectories that are older than 30 days:

   1:  forfiles /p /m *.txt c:\a\test /s /c "cmd /c del @file" /d -30

No comments: