title: %%F variable always referencing the last item in a FOR loop instead of the current one
body: <p>This seems like is should be fairly simple, but I am having trouble getting a FOR loop in DOS to correctly report the current item it is evaluating.</p>
  
  <p>I have a simple DOS batch file that loops through all files in a directory and renames them.  Let's say for example my directory contains the following files:</p>
  
  <pre><code>File1.txt
  File2.txt
  File3.txt
  </code></pre>
  
  <p>I want to remove the TXT extension from each file.  So my batch command looks something like:</p>
  
  <p>@echo off</p>
  
  <pre><code>for %%F in ("*.txt") do (
    echo %%F
    set tmpFile=%%F
    echo %tmpFile%
    set newFile=%tmpFile:~0,-4%.xml
    echo %newFile%
  )
  </code></pre>
  
  <p>My expected output would be:</p>
  
  <pre><code>File1.txt
  File1.txt
  File1.xml
  File2.txt
  File2.txt
  File2.xml
  File3.txt
  File3.txt
  File3.xml
  </code></pre>
  
  <p>Instead the output is:</p>
  
  <pre><code>File1.txt
  File3.txt
  File3.xml
  File2.txt
  File3.txt
  File3.xml
  File3.txt
  File3.txt
  File3.xml
  </code></pre>
  
  <p>It's as if setting %%F to a variable always uses the last file in the collection.</p>
  
  <p>Am I doing something wrong?  Please note I know there are better ways to simply change an extension.  My finished batch file will perform many more actions, but I can't seem to get past this initial step.</p>