Click here for Low cost website hosting!

IP Address Lookup
IP Address

Microsoft Windows Tips And Tricks!


Deleting Files by date at the command prompt with the forfiles command

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
Sample Example:

forfiles /P "C:\program files\docs" /S /M *.tmp /D -1 /C "cmd /c echo @fdate @file & del @file"

Thanks for visiting

Return to Index Page

Valid HTML 4.01 Transitional
Copyright 2019 CSN All Rights Reserved