How do I write a batch file to delete folders and files on a time basis?

前端 未结 2 1205
醉梦人生
醉梦人生 2021-01-21 13:58

Exact Duplicates:

  • How to write a batch file to delete the files which are 5 days or older from a folder?
  • write a batch file to delete 6 days older files
2条回答
  •  长情又很酷
    2021-01-21 14:33

    Batch can be surprisingly powerful but I don't think the kind of date manipulation you want will be practical.

    You can use FOR to split the date into elements and then use SET /A to do the subtraction, but then you're going to need a huge number of IF and GOTO statements to handle cases like subtracting an hour from half past midnight on the 1st of January.

    I think you'd be better off investigating VBS or Powershell.

提交回复
热议问题