它应该很简单,但我无法让它工作!也许有人可以帮助...
我只需要一个程序来检查'07503.csv'文件是否存在,而不是'07504.csv','07505.csv'......直到'07552.csv'。在这里我想结束程序(它被简化了,所以你可以理解我的问题)。
这有效:
SET angle=075
SET velocity=03
SET finalfilename=.csv
SET endofsequency=07552
SETLOCAL EnableDelayedExpansion
:loop
SET currentsequency=%angle%%velocity%
SET fullfilename=%currentsequency%%finalfilename%
:CHECK_FILES
IF EXIST %fullfilename% (
ECHO FILE FOUND: %fullfilename%
GOTO :GO_TROUGHT
) ELSE (
ECHO FILE NOT FOUND: %fullfilename%
GOTO :WRITE_LOG
)
:WRITE_LOG
ECHO %time% missing: %fullfilename%
ECHO %time% missing: %fullfilename% >> FilesMissed.txt
:GO_TROUGHT
FOR /F "tokens=* delims=0" %%A IN ("%velocity%") DO SET velocity=%%A
SET /A velocity+=1
SET velocity=000%velocity%
SET velocity=%velocity:~-2%
PAUSE
IF %currentsequency% NEQ %endofsequency% GOTO loop
:END
PAUSE
但是使用 IF-ElSE 语句不会:
SET angle=075
SET velocity=03
SET finalfilename=.csv
SETLOCAL EnableDelayedExpansion
:loop
SET currentsequency=%angle%%velocity%
SET fullfilename=%currentsequency%%finalfilename%
:CHECK_FILES
IF EXIST %fullfilename% (
ECHO FILE FOUND: %fullfilename%
GOTO :GO_TROUGHT
) ELSE (
ECHO FILE NOT FOUND: %fullfilename%
GOTO :WRITE_LOG
)
:WRITE_LOG
ECHO %time% missing: %fullfilename%
ECHO %time% missing: %fullfilename% >> FilesMissed.txt
:GO_TROUGHT
IF "%velocity%" NEQ "52" (
FOR /F "tokens=* delims=0" %%A IN ("%velocity%") DO SET velocity=%%A
SET /A velocity+=1
SET velocity=000%velocity%
SET velocity=%velocity:~-2%
) ELSE (
GOTO :END
)
PAUSE
GOTO :loop
:END
PAUSE
我的问题是为什么?发生了什么?我不能在 IF-ELSE 中使用 FOR 吗?想...
问候,