title: Batch Script Removing characters from a variable inside a FOR loop
body: <pre><code>SETLOCAL ENABLEDELAYEDEXPANSION
  FOR %%A IN (*.*) DO (
   SET var=%%A
   ECHO !var:~0,-4!
  )
  </code></pre>
  
  <p>Since we're iterating the variable within the FOR loop, you have to use <code>!</code> around the variable, however, in conjunction with the method <code>:~#,-#</code> to remove characters from the end of the variable, it doesn't take.</p>
  
  <p>In my example, we are just removing the extension from the filename. I understand that you can use <code>%%~nA</code> to just get the filename, but this is just an example of usage.</p>
  
  <p>Is there a way to do this inside of the FOR loop? Maybe a different method than what I am using?</p>