0

即使 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 
4

1 回答 1

0

我不确定for循环有什么问题,但你并不真的需要它。's 提供您需要的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
于 2012-09-27T13:05:48.760 回答