title: Batch file: evaluating command output with regex?
body: <p>I have made a Windows batch file based on some examples I have found elsewhere.
  What it does is it parses a folder for a specific file type (.mkv) and then runs mkvmerge.exe from the MKVToolNix folder.
  The command produces an output, listing the different tracks in the container.</p>
  
  <p>The core of the file is </p>
  
  <pre><code> set rootfolder="Z:\Movies"
   for /r %rootfolder% %%a in (*.mkv) do (
     for /f %%b in ('mkvmerge -i "%%a" ^| find /c /i "chapters"') do (
       if [%%b]==[0] (
         echo "%%a" has no chapters
       ) else (
         echo Doing some interesting stuff!
       )
     )
   )
  </code></pre>
  
  <p>The above example is just part of the file, rootfolder is set to the folder I want parsed, of course, and upon finding a file with chapters in it, it will run additional commands.
  It all works beautifully but I also want to check for subtitles at the same time. The find command doesn't take regular expressions or I could just have added "chapters subtitles". My efforts using other commands, like findstr, haven't really worked.
  How do I go about using RegEx here?</p>
  
  <p>This is an example output, running mkvmerge.exe on an .mkv file</p>
  
  <pre><code>mkvmerge.exe -i "Snow White and the Seven Dwarfs (1937) [tt0029583].mkv"
  File 'Snow White and the Seven Dwarfs (1937) [tt0029583].mkv': container: Matroska
  Track ID 0: video (MPEG-4p10/AVC/h.264)
  Track ID 1: audio (DTS)
  Track ID 2: audio (AC-3)
  Track ID 3: subtitles (HDMV PGS)
  Track ID 4: subtitles (HDMV PGS)
  Chapters: 26 entries
  </code></pre>
  
  <p>This example has both subtitle and chapter tracks and the batch file will find the keyword "chapters" (it's set to ignore case). I also want to catch the files that contain the keyword "subtitles" even when there are no chapters.</p>
  
  <p>To clarify my intent here, I want the code to:</p>
  
  <ul>
  <li>Parse through the given folder</li>
  <li>For all .mkv files, do <em>mkvmerge /i</em> which will output (as text) the    streams in that file</li>
  <li>Look at that output and if it contains the word(s) "chapters" and/or    "subtitles" trigger some action.</li>
  </ul>