[英]How can I Delete Files That Do Not Contain Certain Characters Using Windows Batch File?
How can I delete files that do not end with the pattern .PDF_*.pdf
? 如何删除不以模式.PDF_*.pdf
结尾的文件?
AA00A6E2.PDF
AA00A6E3.PDF
AA00A6E3.PDF_01.pdf
AA00A6E3.PDF_02.pdf
AA00A6E3.PDF_03.pdf
I have been trying all sorts of variations around the following syntax: 我一直在尝试围绕以下语法的各种变体:
FOR %%F IN (%varFolderSource%\*.*) DO IF NOT "%%~xF" == "*_*" DEL /F /S "%%F"
But I can't seem to crack it. 但我似乎无法破解它。
%varFolderSource% is a folder path: C:\Temp etc.
I am running this in a Windows 7 batch file. 我在Windows 7批处理文件中运行它。
For /f "delims=" %A in ('dir /b /a-d ^|findstr /i /v /e /r "\.PDF_[a-z0-9]*\.pdf"') do echo %A
Type 类型
for /?
findstr /?
In a batch file use %%A
rather than %A
at command prompt. 在批处理文件中,在命令提示符下使用%%A
而不是%A
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.