批次:(此时意外

时间:2018-02-24 23:24:04

标签: batch-file

我收到此错误

( was unexpected at this time

这就是我所拥有的

@echo off
setlocal EnableExtensions DisableDelayedExpansion

set "File=testdoc.txt"
set "Temp=%TEMP%\%~n0.tmp"

set "TaskNumber=%~1" 

findstr /B /L /M /C:"%TaskNumber%:" "%File%" >nul 2>&1
if errorlevel 1 echo ERROR: %TaskNumber% not found in file "%File%" & goto:eof 

set var="false"
if /I "%~2" == "enable" set var="true"
if "%~2" == "" set var="true"

if "!var!" == "true" (
del "%Temp%" 2>nul
for /F "usebackq tokens=1* delims=:" %%I in ("%File%") do (
     if not "%%I" == "%TaskNumber%" (
        echo %%I:%%J>>"%Temp%"
    ) else (
          set "TextLine=%%I:%%J"    
            if not "%TextLine:~-2%" == ":N" (
                set "TextLine=%TextLine%:N"
                echo %TextLine%>>"%Temp%"
                )
            )

    )   
)


else (
if /I "%~2" == "disable" (
del "%Temp%" 2>nul
for /F "usebackq tokens=1* delims=:" %%I in ("%File%") do (
    if not "%%I" == "%TaskNumber%" (
        echo %%I:%%J>>"%Temp%"
    ) else (
         set "TextLine=%%I:%%J" 
         if "%TextLine:~-2%" == ":N" (
                set "TextLine=%TextLine:~0,-2%"
                echo %TextLine%>>"%Temp%"
                )
            )

    )  
)
)

move /Y "%TempFile%" "%TextFile%" 2>nul

我对此进行了一些研究,并且在大多数帖子中说,使用延迟扩展会有所帮助,但它似乎也没有帮助。任何关于我可能缺少什么的想法

1 个答案:

答案 0 :(得分:0)

c=np.zeros(2)问题外,您还遇到了延迟扩展问题,并且不必要地重置了else变量。

TextLine