下面是一段代码,它正在抛出一个"此时ECHO意外发生了#34;错误:
SET SN_List_Filename=SN_LIST_%DATE:/=%.txt
SET SN_List_Filename_Temp=%SN_List_Filename%.temp
ECHO Date: %DATE:~0,2%-%DATE:~3,2%-%DATE:~-4% > %SN_List_Filename_Temp%
ECHO SN List: >> %SN_List_Filename_Temp%
ECHO. >> %SN_List_Filename_Temp%
IF NOT EXIST %SN_List_Filename% (
ECHO. > %SN_List_Filename%
) ELSE (
SET SN_List=%serial%
SET index=0
SET snCount=1
FOR /f "tokens=* skip=5" %%a IN (%SN_List_Filename%) DO (
SET SN_List=!SN_List!;%%a
FOR /F "tokens=* delims=;" %%b IN ("%SN_List%") DO (
IF %%a==%%b (
ECHO %%b>> %SN_List_Filename_Temp%
)
)
)
)
如果" %% a == %% b"则会引发错误。比较满意。
* N.B。设置enabledelayedexpansion并将ECHO设置为off。