title: Batch file Rename file with variable appended to filename?
body: <p>I want to rename with appended and also remove the extension of all *.jpg</p>
  
  <pre><code>ex. gr1.jpg
  gr2.jpg
  fx1.jpg
  </code></pre>
  
  <p>to</p>
  
  <pre><code>gr1_32dpi
  gr2_32dpi
  fx1_32dpi
  </code></pre>
  
  <p>This is my command</p>
  
  <pre><code>for %a in (*.jpg) do ren "%~a" "%~_32dpi%~xa"
  ren *.jpg .*
  </code></pre>
  
  <p>but this <code>*for %a in (*.jpg) do ren "%~a" "%~na version 1%~xa"*</code> command not working </p>
  
  <p>When saving as .bat then run getting error like this</p>
  
  <blockquote>
    <p>[The following usage of the path operator in batch-parameter<br>
    Substitution is invalid: %~na version 1%~xa"<br>
    For valid formats type CALL /? or FOR /?<br>
    extensio2.bat was unexpected at this time.]  </p>
  </blockquote>
  
  <p>But it works directly run in cmd</p>