title: Windows batch script to continue in loop when scanning files in folder
body: <p>I need to convert all MP4 files in my subdirectories to MKV. So I wrote this script:</p>
  
  <pre><code>@ECHO OFF
  SET oldName=
  SET newName=
  
  FOR /r %%A IN (*.mp4) DO (
      SET oldName=%%A
      SET newName=%%A
      CALL :MAKEMKV
  )
  
  :MAKEMKV
  SET newName=%newName:mp4=mkv%
  IF NOT EXIST %newName% (
      START /B /WAIT ffmpeg -i "%oldName%" -map 0 -map -0:s -codec copy "%newName%"
  )
  </code></pre>
  
  <p>The problem is that only first file in folder is converted and then it exits. But I use <code>for do</code> loop. So I could not get why it exits.</p>
  
  <p>My structure is:</p>
  
  <pre><code>/FOLDER
  ../A/filea.mp4
  ../B/fileb.mp4
  ../C/filec.mp4
  </code></pre>
  
  <p>When I run above program I get only converted <code>filea.mp4</code> to <code>filea.mkv</code> and script exits.<br>
  The other files <code>fileb.mp4</code> and <code>filec.mp4</code> are not converted by the batch file.</p>
  
  <p>What I am missing?</p>