title: Date arithmetic in cmd scripting
body: <p>I need to write a script to change a filename from aDate.txt to bDate.txt where:</p>
  
  <ul>
  <li>aDate is the current system date in <em>yyyymmdd</em> format and </li>
  <li>bDate is the current system date - 1 in <em>yyyymmdd</em> format.</li>
  </ul>
  
  <p>I currently have:</p>
  
  <pre><code>set yy=%date:~6,2%
  set mm=%date:~3,2%
  set dd=%date:~0,2%
  if "%date:~6,1%"==" " set yy=0%yy:~1,1%
  if "%date:~3,1%"==" " set mm=0%mm:~1,1%
  if "%date:~0,1%"==" " set dd=0%dd:~1,1%
  SET sys_date=20%yy%%mm%%dd%
  ECHO %sys_date%
  REM still have to do this bit properly
  SET sys_date_yesterday=%sys_date%a
  move %sys_date%.txt %sys_date_yesterday%.txt
  </code></pre>
  
  <p>but I have no idea how to do the date -1 thing (other than the long winded) subtract 1 from the day and if that is = 0 then subtract one from the month and set the day = to the last day of the new month and so on for years.</p>
  
  <p>Any ideas?</p>