title: for /f run powershell escape characters
body: <p>When I run the following in cmd prompt, it works fine</p>
  
  <pre><code>pushd "C:\Converter"
  for /f "delims=" %g in ('dir "C:\Toconvert" /b /s /ad') do (powershell .\BatchConvert.ps1 "%g" 10)
  popd
  </code></pre>
  
  <p>It executes the command successfully.
  This is the output:</p>
  
  <pre><code>C:\Converter&gt;(powershell .\BatchConvert.ps1 "C:\Toconvert\Prego!PDF" 10 )
  </code></pre>
  
  <p>When I tried running the same command in a .bat file, it fails. Using cmd line to run the bat file I find this is what it is generating:</p>
  
  <pre><code>C:\Converter&gt;for /f "delims=" \Toconvert" /b /s /ad') do (powershell .\BatchConvert.ps1 "g" 10)
  </code></pre>
  
  <p>Why is it dropping off the "%g in ('dir "C:" before the brackets and why is it dropping off the % in the do command? How do I escape characters to get this to work as a .bat?</p>