The "forfiles" command usage from the dos prompt or Batch Script:
In the below example all files in the sample directory and subdirectories with extension *.tmp and 1 day old or older are deleted.
Paramiters that can be used on the command:
P = directory path to use
S = include sub directories
M = file type search
D = date +N is "= to or newer" -N is "= to or older"
C = the command to execute on the files in question
@fdate = a variable for the date of the files
@file = a variable that contains the file in question
forfiles /P "C:\program files\docs" /S /M *.tmp /D -1 /C "cmd /c echo @fdate @file & del @file"
Thanks for visiting mswintips.com.
Return to Index Page
Copyright ©2019 CSN All Rights Reserved