lundi 13 novembre 2017

". was unexpected at this time" generated from batch script line 'if exist [file] (...

relevant code looks like this:

cd /d %~dp0

if exist filename.txt (
    echo %date% %time% *** text... >> filename2.txt
    echo ==============================
    echo ===  text.......           ===
    echo ===  text.......           ===
    echo ===  text....... (text...) ===
    echo ===  text (text... 
    echo ===  text...).
    :loop
        set /p "varx= text: "
    if "%varx%" neq "xxxx" goto loop

 ... more script...

)

Have searched high and low for solutions...

  • was pointed in direction of If statement groupings here: http://ift.tt/2yAnEJo - NO GO

  • was pointed in direction of problems with loops in If blocks, here: (Windows batch) Goto within if block behaves very strangely - NO GO

  • Was pointed in direction of using @setlocal enabledelayedexpansion or @setlocal enableextensions (can't track down where) - NO GO

  • tried passing filename via set /p varfile="filename" and if exist %varfile% - NO GO

  • of course thought there were other parts of code causing error -- NO GO

The thing is that this WAS working for a long while...then I changed what I thought was some innocuous stuff and cannot figure out where the problem lies...

such an obscure problem to solve..ugh!

Aucun commentaire:

Enregistrer un commentaire