Batch file 如何使用FIND语句和嵌套IF条件
我试图在批处理中使用find语句和if条件,但执行没有输入if条件,而是在第一个if语句处停止:Batch file 如何使用FIND语句和嵌套IF条件,batch-file,if-statement,Batch File,If Statement,我试图在批处理中使用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
@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
)
)
学习if的语法,如if/?中所述?。偏执论必须与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
)
)