title: windows batch file with goto command not working
body: <p>I have a problem with GOTO command and affiliated labels. </p>
  
  <p>Facts: Given a bunch of files from a folder (they are log errors) I need to open them and check if they contain a specific string. If yes then eliminate some characters (all the chars after the last appearance of "_", including itself) from the file names and do other operations.</p>
  
  <p>For cutting off the chars I'm using GOTO command in a loop manner as I found it described here: <a href="http://www.robvanderwoude.com/battech_while_loops.php" rel="noreferrer">http://www.robvanderwoude.com/battech_while_loops.php</a></p>
  
  <p>The script is:</p>
  
  <pre><code>@echo off
  setlocal EnableDelayedExpansion
  
  cls
  
  for %%X in (D:\e-pub\outbox\logs\*.*) do (
  
      for /F "tokens=7" %%S in (%%X) do (
  
          if /i "%%S"=="&lt;ml&gt;" (
              SET fisier=%%~nX
              SET cond=!fisier:~-1!
              SET fisier=!fisier:~0,-1!
  
              :loopStart
              rem condition to break the loop
              if !cond!==_ goto loopEnd
              SET cond=!fisier:~-1!
              SET fisier=!fisier:~0,-1!
              goto loopStart
  
              :loopEnd
  
              rem here it should be out of a loop
              rem other stuff to do with var !fisier!
              rem the following line is not executed because of the label loopEnd
              echo !fisier!
          )
      )
  ) 
  
  pause
  </code></pre>
  
  <p>The script is not running because there is an empty line after the label loopEnd?!
  If I'm writing any instructions right after that label they will be executed but the rest of iterations from the first for statement won't be executed (the log errors folder contains more one file)</p>
  
  <p>Can someone provide help?</p>