title: Increment folders names numbering using windows command line
body: <p>Every week I create a new folder and, to keep them in order, I name them with a numbering like <code>01 - day-month</code>, <code>02 - day-month</code>, etc. I have already created the windows cmd script that names the folders according to the date, but now I would like to write the part of the script that puts the number of the folder before the date (keeping the number dashed with a 0).</p>
  
  <p>I have already seen an example here on stackexchange but could not fully understand the code.</p>
  
  <p>This is what I have got so far:</p>
  
  <pre><code>@echo off
  setlocal enableDelayedExpansion
  set "baseName= - "
  set "n=0"
  for /f "delims=" %%F in (
    '2^&gt;nul dir /b /ad "%baseName%*."^|findstr /xri "[0-9]*%baseName%*"'
  ) do (
    set "name=%%F"
    set "name=!name:*%baseName%=!"
    if !name! gtr !n! set "n=!name!"
  )
  set /a n+=1
  md "%n%%baseName%"
  </code></pre>
  
  <p>PowerShell 2.0 is welcome as well.</p>