Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 使用“删除文件”;“某些”;里面的话_Windows_Batch File - Fatal编程技术网

Windows 使用“删除文件”;“某些”;里面的话

Windows 使用“删除文件”;“某些”;里面的话,windows,batch-file,Windows,Batch File,所以我有一个文件夹,里面有大约300个.txt文件,它们的名字如下 ERROR WITH Position Post_20162602_052055.txt ERROR WITH Position Post_20162602_052053.txt ERROR WITH Position Post_20162602_052102.txt INCOMPLETE MESSAGE_20162602_052102.txt EXCEPTION ERROR_20162602_052102.txt 我想创建一

所以我有一个文件夹,里面有大约300个.txt文件,它们的名字如下

ERROR WITH Position Post_20162602_052055.txt
ERROR WITH Position Post_20162602_052053.txt
ERROR WITH Position Post_20162602_052102.txt
INCOMPLETE MESSAGE_20162602_052102.txt
EXCEPTION ERROR_20162602_052102.txt
我想创建一个批处理文件,仅删除文件夹中的
不完整消息\u 20162602\u 052102.txt
异常错误\u 20162602\u 052102.txt
错误。所有文件都是唯一的,它们之间唯一的共同因素是
位置公告
不完整消息
异常错误

我尝试过使用下面的代码,但是它似乎与文件名中的空格有问题,我很确定它是在文件中查找,而不是在文件名中查找

@echo off
FOR /F"delims=;" %%a in ('findstr /m /i "EXCEPTION ERROR INCOMPLETE MESSAGE" C:\test\*.txt') do (
@echo %%a
del %%a
)
我查看了bash的
FIND
函数,但找不到为文件名中的特定单词设置a
“search variable”
的方法

del“不完整消息*.txt”异常错误*.txt“
是如何处理的。

尝试如下:

@echo off
setlocal EnableDelayedExpansion
Set Folder=c:\Dataexports
set Log=FileList.txt
If Exist %Log% Del %Log%
Set Exp="EXCEPTION ERROR" "INCOMPLETE MESSAGE"
(
    For %%a in (%Exp%) Do (
        For /f "delims=" %%b in ('Dir /s /b "%Folder%\*.txt" ^| find %%a /i') do ( set File=%%b
            echo "!File!" & Del "!File!"
        )
    )   
)>>%Log% 2>&1
Start "" %Log%