title: While loop in batch
body: <p>Here is what I want, inside the <code>BACKUPDIR</code>, I want to execute <code>cscript /nologo c:\deletefile.vbs %BACKUPDIR%</code> until number of files inside the folder is greater than 21(<code>countfiles</code> holds it).
  Here is my code:</p>
  
  <pre><code>@echo off
  SET BACKUPDIR=C:\test
  for /f %%x in ('dir %BACKUPDIR% /b ^| find /v /c "::"') do set countfiles=%%x
  
  for %countfiles% GTR 21 (
  cscript /nologo c:\deletefile.vbs %BACKUPDIR%
  set /a countfiles-=%countfiles%
  )
  </code></pre>