我试图批量使用find
语句和if
条件,但执行不会进入if
条件,它会在第一个if
停止声明:
@echo off
find /i "DA" E:\LogFiles_List.txt > nul
pause
if errorlevel 1
(
echo DA not found
pause
)
else
(
find /i "Error" E:\hello.txt > nul
if errorlevel 0 (
echo Error found in hello.txt
pause
) else (
echo Error NOT found in thefile.txt
pause
)
)
答案 0 :(得分:0)
研究if
中描述的if /?
语法。 parantheses必须与if
或else
在同一行。这是更正后的代码:
@echo off
find /i "DA" E:\LogFiles_List.txt > nul
pause
if errorlevel 1 (
echo DA not found
pause
) else (
find /i "Error" E:\hello.txt > nul
if errorlevel 0 (
echo Error found in hello.txt
pause
) else (
echo Error NOT found in thefile.txt
pause
)
)