title: Remux MKV removing subtitles and unwanted audio tracks using mkvmerge in batch file
body: <p>I am creating a windows batch file to find all mkv files in a folder, check if it has multiple audio tracks and subtitles. If it does, remove all subtitles and all audio tracks except for ENG and UND. However, when I run the batch file it crashes? I don't know why it started doing that. Plus the variable wasn't setting before. Clean is always false. Please help.</p>
  <pre><code>@echo on
  setlocal ENABLEDELAYEDEXPANSION
  
  set rootfolder=&quot;C:\Users\User\Desktop\mov&quot;
  set &quot;clean=false&quot;
  
  echo Enumerating all MKVs under %rootfolder%
  
  for /r %rootfolder% %%a in (*.mkv) do (   
   for /f %%s in ('mkvmerge -i &quot;%%a&quot; ^| find /c /i &quot;subtitles&quot;') do (
    if NOT [%%s]==[0] (
     set &quot;clean=true&quot;
    )
  )
  
  for /f %%b in ('mkvmerge -i &quot;%%a&quot; ^| find /c /i &quot;audio&quot;') do (
   if [%%b]gtr[1] (
    set &quot;clean=true&quot;
   )
  )
          
  if %clean%==&quot;true&quot; (
   mkvmerge -o &quot;%%~dpna (clean)%%~xa&quot; -a und,eng -s und,eng --no-subtitles &quot;%%a&quot;
  )
  )
  echo Done
  pause
  </code></pre>