我想要delete
早于以下时间的无扩展名文件7
名字结尾为的日子_C
.
示例文件:
B_C_A1_C
B_C_A2_C
B_C_A3_A
test.txt
My code:
SET mypath=%cd%\downloads
ForFiles /p %mypath% /d -7 /c "cmd /c del /q %mypath%\*_C
当我执行代码时,它会删除包含以下内容的所有文件_C
,但我只想删除以_C
并且年龄大于7
days.
我怎样才能解决这个问题?
欲了解更多信息文件文档 https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/forfiles, see 批处理文件删除超过N天的文件 https://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days?rq=1.
通配符表达式*_C
选择以以下结尾的任何文件_C
,无论它是否有扩展名。
最终的代码非常复杂:
forfiles /p "%cd%" /m *_C /C "cmd /c \"echo @file^|find \".\" ^|^| del @path\""
Using *_C
将选择以下内容:
anything without periods_C
It will NOT选择以下内容:
any.thing_C
anything.txt._C
anything containing periods_C
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)