title: Windows Batch File to delete all but a few folders
body: <p>I'm writing a .bat script to delete all folders but roughly five pre-set ones. What I've done is make a for loop that addresses every folder, then the forloop checks through an IF statement if the folder's name matches a string, in which case it uses GOTO to go to the line below the RD command, so that the removing is skipped. </p>
  
  <p>However, this ends the for loop, meaning every folder until the first exception gets deleted. </p>
  
  <p>Is there a better way to achieve what I want, or are there tweaks on my script?</p>
  
  <pre><code>@echo off
  echo Starting...
  for /d %%i in ("C:\demo\*") do (
      if "%%i" == "C:\demo\mark" goto skipdel
      if "%%i" == "C:\demo\pjotr" goto skipdel
      if "%%i" == "C:\demo\jasper" goto skipdel
      rd /s /q %%i
      echo Deleted
      :skipdel
  )
  echo Done.
  pause
  </code></pre>