gpt4 book ai didi

batch-file - 使用批处理文件删除超过 6 个月的文件

转载 作者:行者123 更新时间:2023-12-03 11:21:00 25 4
gpt4 key购买 nike

我必须删除超过 6 个月的 tmp 文件。我在批处理文件中运行了此命令,该文件删除了 180 天以上的文件。

forfiles /p "C:\Backup" /s /m *.tmp /c "cmd /c Del @path" /d -180

但我想通过 number of month而不是 number of days .任何想法都会非常有帮助。提前致谢

最佳答案

如果您真的想提供日、月、年中的任何一个作为参数,您也可以使用 powershell 命令。

例子:

Get-ChildItem –Path  “C:\Backups” –Recurse | Where-Object CreationTime –lt (Get-Date).AddMonths(-6) | Remove-Item

关于batch-file - 使用批处理文件删除超过 6 个月的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31933907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com