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,753
  • 72
  • 57
  • 129
user1089660
  • 1,191
  • 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
  • 404
  • 1
  • 4
  • 16
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?