title: Automatically delete folder contents after 'n' days - Windows 10
body: <p>I am wondering if someone can tell me how I can make a folder in windows that will automatically delete any files within that have been there for more than 'n' days, say maybe 7 for a week.</p>
  
  <p>I have found a similar question that was answered well <a href="https://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days" title="Stack Overflow Answer">here</a>, though im not sure if it works on windows 10.  Also, would this be a '.bat' file? And, how do I make the batch file run automatically?</p>
  
  <p>Thanks!</p>
  
  <p>Edit:  I created a .bat file, starting with the mentioned answer:     </p>
  
  <pre><code>forfiles /p "C:\what\ever" /s /m *.* /D -&lt;number of days&gt; /C "cmd /c del 
  @path"    
  </code></pre>
  
  <p>Which I changed to:</p>
  
  <pre><code>forfiles /p "F:\Movies" /s /m *.* /D -&lt;1&gt; /C "cmd /c del @path"
  </code></pre>
  
  <p>exactly, to test it.  The folder 'Movies' has a bunch of things whos date modified is from very long ago.  I created a task with Task Scheduler (Thanks Thomas)  and it didnt delete anything.</p>
  
  <p>I also tried running the batch manually, tried changing it to 1 minute, tried putting it in the folder that its deleting from, and ran it as admin.  Nothing worked.  I have permissions on the folder.</p>
  
  <p>Does anyone have any suggestions?  Did I do something wrong with the code?</p>