问题:
I am looking for a way to delete all files older than 7 days in a batch file. 我正在寻找一种删除批处理文件中所有7天以上的文件的方法。 I've searched around the web, and found some examples with hundreds of lines of code, and others that required installing extra command line utilities to accomplish the task. 我在网上搜索,发现了一些包含数百行代码的示例,还有一些示例需要安装额外的命令行实用程序才能完成任务。
Similar things can be done in BASH in just a couple lines of code. 只需几行代码即可在BASH中完成类似的操作。 It seems that something at least remotely easy could be done for batch files in Windows. 似乎可以对Windows中的批处理文件至少进行一些远程操作。 I'm looking for a solution that works in a standard Windows command prompt, without any extra utilities. 我正在寻找一种可以在标准Windows命令提示符下运行且没有任何其他实用程序的解决方案。 Please no PowerShell or Cygwin either. 请不要使用PowerShell或Cygwin。
解决方案:
参考一: https://stackoom.com/question/DHS/批处理文件以删除超过N天的文件参考二: https://oldbug.net/q/DHS/Batch-file-to-delete-files-older-than-N-days
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4354946