简体   繁体   English

如何使用Windows批处理文件删除不包含某些字符的文件?

[英]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.

相关问题 在批处理文件中,如何删除非特定类型的所有文件 - In a batch file, how do I delete all files NOT of a certain type 如何使用批处理文件在 Windows 10 中删除具有特定名称的文件? - How to delete files with specific names in windows 10 using batch file? 如果使用Windows批处理文件将文件清空,如何检测(和删除)文件? - How do I Detect (and Delete) a File if it is Empty using a Windows Batch File? 是否可以使用Windows批处理文件删除某些rar文件? - Is it possible to use a Windows batch file to delete certain rar files? 如何在Windows批处理中将文件通过管道传输到加密的,受密码保护的zip文件中,然后删除原始文件? - How do I pipe a file into an encrypted, password protected zip file, then delete the original file, in Windows batch? 如何删除子目录中的文件和文件夹,但在Ruby中跳过某些文件名的删除? - How do I delete files and folders in sub-directories but skip delete for certain file names in Ruby? 如何使用Windows批处理文件查找特定目录? - How can I find specific directories using Windows batch file? 如何使用批处理文件捕获Windows硬件配置? - How can I capture Windows hardware configuration using a batch file? Windows批处理文件删除桌面上的所有文件 - Windows batch file to delete all files on desktop Windows 批处理文件 - 匹配包含模式但不以相同模式结尾的文件 - Windows Batch file - matching files that contain a pattern but DO NOT end with that same pattern
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM