title: Batch file - changing variable value in a for loop
body: <p>I have following code snippet</p>
  
  <pre><code>    setlocal enableextensions enabledelayedexpansion
      set b=123
      for %%f in (.\input\*.mgc) do (
         set "b=%%~nf"
         echo %b%
      )
  </code></pre>
  
  <p>I am expecting it to output file name with no extension but I always get "123". I concluded it has something with late expansion but not quite sure where the problem comes from. I have also tried with <code>echo !b!</code> but in that situation it outputs only "!b!"</p>