title: Forfiles command in For Loop
body: <p>Simplified working Script part from a Batch File</p>
  <pre><code>for %%F in 
  (
  C:\A\*.TXT
  ) do (
  echo %%F
  )
  </code></pre>
  <p>This prints out all .TXT filepaths from folder A.</p>
  <p>I would like to add a forfiles extension in order to only get .TXT files /D -2</p>
  <pre><code>for %%F in ('
  forfiles /P &quot;C:\A\&quot; /M *.TXT /D -2 /C &quot;cmd /c echo @PATH&quot;
  ') do 
  (
  echo %%F
  )
  </code></pre>
  <p>But this only prints the forfiles command as string:</p>
  <pre><code>'forfiles
  /P
  &quot;C:\A\&quot;
  /M
  /D
  -2
  /C
  &quot;cmd /c echo @PATH&quot;'
  </code></pre>
  <p>How do I have to hand over the forfiles command to make this work - if possible at all.</p>