title: Windows script to delete everything but image file extensions
body: <p>I want to create a script on Windows 7 to delete everything in a directory that is not a picture.
  So</p>
  
  <pre><code>    for all files in directory X
  
      if file y does not have extension in (.png, .gif, .jpeg)
  
      delete y
  
      end
  </code></pre>
  
  <p>that's it</p>
  
  <p>how can I find or create such a script</p>
  
  <p>mind you, some pictures are important, so this script has to work correctly :) I don't think I should be experimenting here, and even if I tested my own script on a small directory with experimental files, I am not confident that I should try it.</p>
  
  <p>I have this code as suggested:</p>
  
  <pre><code>::extensions are delimited with space // filename is del_stuff.bat
  
  set "extensions_list=.png .gif .jpeg .bmp .jpg "
  pushd "C:\Users\denman\Desktop\xxx\"
  for /f "delims=" %%f in ('dir /b ^|findstr /i /e /v "%extensions_list%" ') do (
          echo del /q /f "%%~f" 
  )
  popd
  </code></pre>
  
  <p>But I get this error:</p>
  
  <p><img src="https://i.stack.imgur.com/iz6oV.jpg" alt="enter image description here"></p>