title: how to read a file from line x to line y (dos/win batch file)
body: <p>I have a series of log files.</p>
  
  <p>I parse these log files with findstr to determine the first instance of a string of text, then return the file name and the line lumber the match was found on as variables.</p>
  
  <p>I then use findstr to parse the file the match was found in for another text string.  I return the matching line number as a variable.</p>
  
  <p>I now have the file, the starting and ending line numbers.</p>
  
  <p>I need to return the block of text between my line numbers.</p>
  
  <p>All output is redirected to a textfile represented by the variable casenotes</p>
  
  <p>Here is my code:</p>
  
  <pre><code>:test
  echo:            &gt;&gt; %casenotes%
  echo:   test         &gt;&gt; %casenotes%
  for /f "tokens=1,2* delims=:" %%a in ('findstr /N /C:"Optimize ThreadPools" *_MAGT_*.txt') do set startline=%%b &amp; set filefoundin=%%a &amp; goto part2
  :part2
  for /f "tokens=1,2* delims=:" %%a in ('findstr /N /C:"After optimization" %filefoundin%') do set endline=%%a &amp; goto part3
  :part3
  echo:                       &gt;&gt; %casenotes%
  echo: filefound in: %filefoundin%       &gt;&gt; %casenotes%
  echo: startline is: %startline%     &gt;&gt; %casenotes%
  echo: endline is:   %endline%       &gt;&gt; %casenotes%
  echo:                       &gt;&gt; %casenotes%
       echo: now do something magic to read everything between lines %startline% and %endline% from %filefoundin% and redirect that output to %casenotes%
  </code></pre>
  
  <p>Any advice appreciated!</p>