title: get value from cropdetect
body: <p>I have been able to parse the output of <code>ffmpeg cropdetect</code> with a batch file in Windows 7 to get crop=640:480:0:0 but the process goes too far and processes the last mp4 or mkv file twice.
  I run the first for loop to get a list of mkv or mp4 files in the folder and run a process <code>:gin</code>.
  The second <code>for</code> loop to run <code>ffmpeg</code> skipping ahead 30 seconds and run <code>cropdetect</code> on only one second of video with the long file of 60 plus entrys of
  <code>[Parsed_cropdetect_0 @ 0000000002ef8f00] x1:0 x2:1279 y1:0 y2:719 w:1280 h:720 x:0 y:0 pts:1081 t:1.081000 crop=1280:720:0:0</code>
  going to <code>tmp.txt</code>
  <code>Tail</code> gives me the last line of <code>tmp.txt</code> and outputs to a new text file <code>tmp1.txt</code>
  The last <code>for</code> loop looks at <code>tmp1.txt</code> and returns the 14th. token of crop=1280:720:0:0</p>
  
  <p>This is a Zeranoe Windows static build and I have tails for windows installed.</p>
  
  <p>I have tried...
  different for loops </p>
  
  <pre><code>for %g in (*.mp4, *.mkv) do set this=%g
  </code></pre>
  
  <pre><code>for /f "delims=*" %g in ('dir /b /o:n *.mp4, *.mkv') set this=%g
  </code></pre>
  
  <p>I have also tried to have <code>tail</code> output overwrite the input with <code>tail -1 tmp.txt &gt; tmp.txt</code></p>
  
  <p>this all works but is not as elegant.
  what I have so far,</p>
  
  <pre><code>for /f "delims=*" %%g in ('dir /b /o:-n *.m??') do set cdet=%%g&amp;&amp; call :gin
  
  :gin
  
  ffmpeg -hide_banner -ss 00:0:30.000 -i "%cdet%" -t 1 -vf cropdetect -f null -2&gt;&amp;1 | findstr /c:"crop=" &gt; tmp.txt 
  
  tail -1 tmp.txt  &gt;tmp1.txt
  
  for /f "usebackq tokens=14" %%a in ("tmp1.txt") do set line=%%a
  
  del tmp*.txt
  
  echo %line%
  </code></pre>
  
  <p>I would like to see if there is a better way to do this without creating temp files and overwriting already processed files.</p>
  
  <p>for those interested the updated script is:</p>
  
  <pre><code>for /F "eol=| delims=" %%I in ('dir /a-d /b /o:-n *.mkv 2^&gt;nul') do set "cdet=%%I" &amp;&amp; call :gin
  
  goto :end
  :gin
  ffmpeg -hide_banner -ss 00:0:30.000 -i "%cdet%" -t 1 -vf cropdetect -f null - 2&gt;&amp;1 | findstr /c:"crop=" &gt;tmp1.txt
  for /f "usebackq tokens=14" %%a in ("tmp1.txt") do set line=%%a
  del tmp*.txt
  echo %line%
  pause
  :end
  exit /b
  </code></pre>