Batch file to delete files older than N days

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

    Run the following commands:

    ROBOCOPY C:\source C:\destination /mov /minage:7
    del C:\destination /q
    

    Move all the files (using /mov, which moves files and then deletes them as opposed to /move which moves whole filetrees which are then deleted) via robocopy to another location, and then execute a delete command on that path and you're all good.

    Also if you have a directory with lots of data in it you can use /mir switch

提交回复
热议问题