title: How to get substring of a local variable in loop?
body: <p>I want to write a script to get all file names in a directory and also exclude file name end with <strong><em>all</em></strong>.</p>
  
  <p>I've came up with below script but it does not work, could anyone help me?</p>
  
  <pre><code>for /R "%SOME_DIRECTORY%" %%f in (*.testcase) do (
      set CURRENT_TESTCASE=%%~nf
      if not %CURRENT_TESTCASE:~-3%==all  (
          echo %%~nf &gt;&gt; "%FILELIST%"
      )
  )
  </code></pre>