0

what is the CMD command to delete the files which is two days older from a particular folder when we run a batch file?

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
user1089660
  • 1,171
  • 2
  • 7
  • 6

2 Answers2

1

You could use FORFILES command together with DEL: FORFILES has an option to filter files older than x days and than execute another command on filtered files.

forfiles /P "path you want to search files" /S /D -2 /C "cmd /c del @file"

FORFILES is a native command under Vista/Windows7/2008, you can get it from the Resource Kit for Windows XP. Note that the syntax may change a little depending on version of FORFILES you're using.

Luca Clavarino
  • 355
  • 1
  • 3
  • 15
0

You could use the fileDate variable, and compare it to the current date, then if it is 2 days or older, you run the eraser over it?