title: Delete all but one file loop with bat script
body: <p>I have a loop in a batch file to delete all but one file in a directory (Windows 7).  But it hangs up because it still sends the commands to the screen, even though I'd thought I'd suppressed it.  Here is the command I'm using:</p>
  
  <pre><code>for %i in (*) do if not %i == UPDATE.BAT del /s %i &gt;nul 2&gt;&amp;1
  </code></pre>
  
  <p>Tested my batch script, log shows it stops right at this command.  Tested the command at the command line, outputs the "del /s file.ext >nul 2>&amp;1" command to the prompt for each file in the directory, which is what causes my batch file to hang.  </p>
  
  <p>What do I need to change here?</p>