title: Batch Script: Delete folder and it's contents created over X days ago
body: <p>I have a backup folder containing a bunch of folders and .zip files.</p>
  
  <p>I basically want to create a batch script (which runs nightly) that deletes all folders (and their contents) which were created X days or more ago.</p>
  
  <p>I tried the following FORFILES command however it just deletes file but not folders:</p>
  
  <pre><code>@echo off
  :: set folder path
  set dump_path=C:\Users\sw\Desktop\Test
  
  :: set min age of files and folders to delete
  set max_days=1
  
  :: remove files from %dump_path%
  forfiles -p %dump_path% -m *.* -d -%max_days% -c "cmd  /c del /q @path"
  
  :: remove sub directories from %dump_path%
  forfiles -p %dump_path% -d -%max_days% -c "cmd /c IF @isdir == TRUE rd /S /Q @path"
  </code></pre>
  
  <p>Looking forward to your help.</p>
  
  <p>Steven</p>