即使IF语句成功,我也无法在下面的代码中找到forloop

时间:2022-05-17 02:08:40

I am unable to come out of the for loop in the following code even if the IF statement is successful. The present scenario is the code is going through the 'for loop' completely and not moving to :next if the if statement is successful. I don't know what to do?

即使IF语句成功,我也无法在以下代码中退出for循环。目前的情况是代码完全通过'for循环'而不是移动到:如果if语句成功则返回next。我不知道该怎么办?

FOR %%A IN (2,3,4) DO GOTO %%A

:2
echo wscript.echo ^(Date^(^)-2^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

:3
echo wscript.echo ^(Date^(^)-3^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

:4
echo wscript.echo ^(Date^(^)-4^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

:NEXT 
ECHO ^<TD WIDTH="25%" VALIGN="TOP" HEIGHT=1^>>>c.html
ECHO ^<FONT FACE="Arial" SIZE=1 COLOR="#808080"^>^<P^>%ydate2%^</FONT^>^</TD^>>>c.html
ECHO ^<TD WIDTH="25%" VALIGN="TOP" HEIGHT=1^>>>c.html
ECHO ^<FONT FACE="Arial" SIZE=1 COLOR="#808080"^>^<P^>%CDate%^</FONT^>^</TD^>>>c.html
GOTO END 

1 个解决方案

#1


0  

I'm not sure what is wrong with the for loop but you don't really need it. The if's provide all the flow control you need.

我不确定for循环有什么问题,但你真的不需要它。 if提供您需要的所有流量控制。

REM Starts here
echo wscript.echo ^(Date^(^)-2^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

REM If file doesn't exist fall over to here, same with the others
echo wscript.echo ^(Date^(^)-3^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

echo wscript.echo ^(Date^(^)-4^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

:NEXT 
ECHO ^<TD WIDTH="25%" VALIGN="TOP" HEIGHT=1^>>>c.html
ECHO ^<FONT FACE="Arial" SIZE=1 COLOR="#808080"^>^<P^>%ydate2%^</FONT^>^</TD^>>>c.html
ECHO ^<TD WIDTH="25%" VALIGN="TOP" HEIGHT=1^>>>c.html
ECHO ^<FONT FACE="Arial" SIZE=1 COLOR="#808080"^>^<P^>%CDate%^</FONT^>^</TD^>>>c.html
GOTO END

#1


0  

I'm not sure what is wrong with the for loop but you don't really need it. The if's provide all the flow control you need.

我不确定for循环有什么问题,但你真的不需要它。 if提供您需要的所有流量控制。

REM Starts here
echo wscript.echo ^(Date^(^)-2^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

REM If file doesn't exist fall over to here, same with the others
echo wscript.echo ^(Date^(^)-3^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

echo wscript.echo ^(Date^(^)-4^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~4,4%
set ydate2=%m%-%d%-%y%
echo yesterday was %ydate2%
IF EXIST ATELBSNT40_complete_txs_%ydate2%.log GOTO :NEXT

:NEXT 
ECHO ^<TD WIDTH="25%" VALIGN="TOP" HEIGHT=1^>>>c.html
ECHO ^<FONT FACE="Arial" SIZE=1 COLOR="#808080"^>^<P^>%ydate2%^</FONT^>^</TD^>>>c.html
ECHO ^<TD WIDTH="25%" VALIGN="TOP" HEIGHT=1^>>>c.html
ECHO ^<FONT FACE="Arial" SIZE=1 COLOR="#808080"^>^<P^>%CDate%^</FONT^>^</TD^>>>c.html
GOTO END