Batch file to delete files older than N days

前端 未结 24 2469
没有蜡笔的小新
没有蜡笔的小新 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:40

    Use forfiles.

    There are different versions. Early ones use unix style parameters.

    My version (for server 2000 - note no space after switches)-

    forfiles -p"C:\what\ever" -s -m*.* -d -c"cmd /c del @path"
    

    To add forfiles to XP, get the exe from ftp://ftp.microsoft.com/ResKit/y2kfix/x86/

    and add it to C:\WINDOWS\system32

提交回复
热议问题