Community
    • Login

    Possible bug found when processing nested parentheses in a batch script

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 3.8k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Josiah DealJ Offline
      Josiah Deal
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • dailD Offline
        dail
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • Josiah DealJ Offline
          Josiah Deal
          last edited by

          Sure,


          setlocal ENABLEDELAYEDEXPANSION
          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:
          title SYNC IS COMPLETE
          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
          )
          )
          )
          )
          )
          )
          endlocal
          echo ├─────────────────────────────────────────────┐>> SyncLog.log
          echo │ SYNC ENDED: %DATE% at %TIME% │>> SyncLog.log
          echo └╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥╥┘>> SyncLog.log
          goto :eof
          :GetTime
          set CurrentTime=%TIME%
          goto :eof


          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors