title: Forfiles Batch Script (Escaping @ character)
body: <p>I'm working on a batch script that will let me delete files older then a set period using <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a>. For now, I'm aiming at printing the files that will be deleted.</p>
  
  <p>The forfiles invocation I'm using works flawlessly from a cmd.exe shell, but as soon as I embed it into a batch script, it barfs. I suspect that this is due to the @ character not being escaped properly, but I'm not certain.</p>
  
  <p>The command I'm running is:</p>
  
  <pre><code>forfiles /S /P "r:\" /m *.bak /d -10 /c "cmd /c echo @PATH"
  </code></pre>
  
  <p>And it results in the following error:</p>
  
  <pre><code>ERROR: Invalid argument/option - '@PATH'
  Type "FORFILES /?" for usage.
  </code></pre>
  
  <p>I've googled all over the place and tried a few different schemes for escaping the @PATH component. Everything from <strong>@@PATH</strong>, to <strong>\"@PATH\"</strong> with no results. </p>
  
  <p>Any help would be appreciated!</p>
  
  <p>I should also note that I'm basing a lot of my knowledge of forfiles from <a href="http://winhlp.com/node/180" rel="noreferrer">here.</a></p>