如果批处理脚本中的条件不起作用 [英] If condition in batch script not working
问题描述
在下面的批处理脚本下运行我的第二个IF条件不起作用:
批次代码:
set count_slu = 0
for %% A in(C:\ SLU \ * accounts * .xml )DO SET / A count_slu + = 1
ECHO Netsol帐户文件SLU_COUNT:%count_slu%>> C:\ SLU \ Netsol_SLU_File_Delay\Net_Account_Log_%dt%。txt
echo ============= Netsol ACCOUNTS日志已完成(%dt%%时间:~0.2%:%时间:~3,2%:%时间:~6,2%)==========>> \\ TDC1FIL001 \Systems\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt
echo%count_slu%>> C:\ Systems \ SLU \ Netsol_SLU_File_Delay\Net_Account_Log_%dt%。txt
if%count_slu%EQU 0(Echo get out>> ; C:\ SLU \ Netsol_SLU_File_Delay\Net_Account_Log_%dt%。txt)
echo结束C:\ SLU \ Netsol_SLU_File_Delay \ Net_Account_Log_%dt%.txt
日志文件输出:
============ = Netsol帐户日志已完成(11_10_2018 16:45:59)==========
0
结束
< br $> b $ b
为什么if%count_slu%EQU 0(Echo get out>> C:\ SLU \ Netsol_SLU_File_Delay\Net_Account_Log_%dt%。txt)
不打印输出?
我尝试了什么:
尝试更改案例,空格,无法理解
Hi,
On running below batch script my second last IF condition is not working:
Batch code:
set count_slu=0
for %%A in (C:\SLU\*accounts*.xml) DO SET /A count_slu+=1
ECHO Netsol ACCOUNTS File SLU_COUNT: %count_slu% >> C:\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt
echo ============= Netsol ACCOUNTS Log Completed (%dt% %time:~0,2%:%time:~3,2%:%time:~6,2%)========== >> \\TDC1FIL001\Systems\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt
echo %count_slu% >> C:\Systems\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt
if "%count_slu%" EQU 0 ( Echo get out >> C:\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt)
echo End C:\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt
LOG FILE OUTPUT:
============= Netsol ACCOUNTS Log Completed (11_10_2018 16:45:59)==========
0
END
Why did the if "%count_slu%" EQU 0 ( Echo get out >> C:\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt)
DID NOT PRINT THE OUTPUT ?
What I have tried:
Tried changing the case , spaces, couldnt understand
推荐答案
if "%count_slu%" EQU 0 ( Echo get out >> C:\SLU\Netsol_SLU_File_Delay\Net_Account_Log_%dt%.txt)
删除%count_slu%
周围的双引号,或者围绕 0
添加双引号。您试图将0
与 0
进行比较。
Remove the double quotes around "%count_slu%"
, or add double quotes round the 0
. You are trying to compare "0"
with 0
.
这篇关于如果批处理脚本中的条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!