Batch file to delete files older than N days

前端 未结 24 2531
没有蜡笔的小新
没有蜡笔的小新 2020-11-21 11:11

I am looking for a way to delete all files older than 7 days in a batch file. I\'ve searched around the web, and found some examples with hundreds of lines of code, and oth

24条回答
  •  星月不相逢
    2020-11-21 11:45

    For windows 2012 R2 the following would work:

        forfiles /p "c:\FOLDERpath" /d -30 /c "cmd /c del @path"
    

    to see the files which will be deleted use this

        forfiles /p "c:\FOLDERpath" /d -30 /c "cmd /c echo @path @fdate"
    

提交回复
热议问题