Batch file to delete files older than N days

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

    If you have the XP resource kit, you can use robocopy to move all the old directories into a single directory, then use rmdir to delete just that one:

    mkdir c:\temp\OldDirectoriesGoHere
    robocopy c:\logs\SoManyDirectoriesToDelete\ c:\temp\OldDirectoriesGoHere\ /move /minage:7
    rmdir /s /q c:\temp\OldDirectoriesGoHere
    

提交回复
热议问题