title: Batch file for loop
body: <p>I am writing a batch file to run on Windows server 2008 R2, it has a <code>for</code> loop in it and no matter how many tutorials I read online and try, it won't run the for loop.</p>
  
  <pre><code>echo "Starting blur detection..."
  if not exist %root%\output mkdir output
  set tempnum = dir root | find /i "file"
  set num = tempnum-5
  for /l %idx in (0, 1, num) do (
     %root%\blurDetection.exe %root%\%img%__%idx%.tif %root%\output
     echo "blurDetection" %idx " of " %num )
  </code></pre>
  
  <p>Windows powershell says "idx was unexpected at this time."
  Any suggestions?</p>
  
  <p>EDIT: Actually I think this line is causing the problem, I don't think it is getting and integer value in return.</p>
  
  <pre><code>set tempnum = dir root | find /i "file"
  </code></pre>