Possible bug found when processing nested parentheses in a batch script

  • Hello,

    I’ve discovered that when using Notepad++ to edit batch files, it seems to have an issue keeping track of which parentheses pair up together in the file. Obviously this doesn’t affect actual processing of the batch file when it’s run, but it does make editing complex batch files rather difficult as I am relying on the parentheses to know where I’m at in the script.

    My “workaround” was to paste the batch file into an html file between two <script> tags so that it would correctly process the layers of parentheses so I could see where I’m at. Of course, this means that I’m losing out on the other color coding for the batch variables, etc. however.

    Here is a link to a screenshot that illustrates the issue better:
    https://www.dropbox.com/s/udnqswdklol7232/Notepad%2B%2B Batch Editor Issue.PNG?dl=0

    Thank you

  • Could you paste the actual text so we can copy/paste it ourselves into N++?

  • Sure,

    echo ┌╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨╨┐>> SyncLog.log
    echo │ SYNC STARTED: %DATE% at %TIME% │>> SyncLog.log
    echo ├─────────────────────────────────────────────┘>> SyncLog.log
    for /F “skip=5 tokens=" %%A in (SyncConfig.txt) do (
    for /F "tokens=3 delims= ,=, " %%B in (‘echo %%A^| findstr /i /c:“Source Drive”’) do (set SourceDrive=%%B)
    for /F "tokens=6-10 delims= " %%A in (‘dir !SourceDrive!^| findstr /i Volume^| findstr /v Serial’) do (
    set SourceDriveName=%%A %%B %%C %%D %%E
    echo │ The source drive is set to !SourceDrive! ^(!SourceDriveName!^)>> SyncLog.log
    for /F "skip=9 tokens=
    ” %%A in (SyncConfig.txt) do (
    for /F %%B in (‘echo %%A^| findstr /i /v /c:“Not Included”’) do (
    if NOT EXIST %%B:\ (
    call :GetTime
    echo │ !CurrentTime! %%B:\ does not exist and was not synced>> SyncLog.log
    if EXIST %%B:\ (
    set NetworkDrive=FALSE
    for /F “skip=5 tokens=2 delims= " %%C in (‘net use^| findstr /v command’) do (if “%%B:”==”%%C" (set NetworkDrive=TRUE))
    if !NetworkDrive!==TRUE (
    call :GetTime
    echo ├ !CurrentTime! %%B:\ is a network drive and was not synced>> SyncLog.log
    if !NetworkDrive!==FALSE (
    title SYNCING !SourceDrive! TO %%B:
    robocopy /MIR !SourceDrive! %%B:
    if %ERRORLEVEL% GEQ 8 (
    call :GetTime
    echo █►!CurrentTime! An error occured when robocopy attempted to sync from !SourceDrive! to %%B:>> SyncLog.log
    if %ERRORLEVEL% LSS 8 (
    for /F "tokens=6-10 delims= " %%C in (‘dir %%B:^| findstr /i Volume^| findstr /i /v Serial’) do (
    call :GetTime
    echo ├►!CurrentTime! %%B:\ ^(%%C %%D %%E %%F %%G^) was successfully synced with !SourceDrive! ^(!SourceDriveName!^)>> SyncLog.log
    echo ├─────────────────────────────────────────────┐>> SyncLog.log
    echo │ SYNC ENDED: %DATE% at %TIME% │>> SyncLog.log
    echo └╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥┘>> SyncLog.log
    goto :eof
    set CurrentTime=%TIME%
    goto :eof

Log in to reply