Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just wiped my laptop and am starting to move files back on to it now. How can I keep certain folders clean automatically? For example, is there an easy way to automatically deletes all of the contents in a folder older than 2 weeks, and have this process run daily? That would really help in keeping things like my downloads folder from filling with junk.

This is on Windows 7 64-bit.

share|improve this question
What operating system are you using? – Daniel Beck Aug 6 '12 at 17:13
Windows 7 64-bit. Added that to the question. That little detail somehow always slips my mind. – Nick Anderegg Aug 6 '12 at 17:24
up vote 1 down vote accepted

You create batch script that deletes content of download folder. And then create windows version of cron and run it on designated intervals.

Batch to delete contents of my folder.

FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" DEL /Q "D:\myfolder\*.*"

Delete folders older than N

forfiles -p "C:\what\ever" -s -m *.* -d <number of days> -c "cmd /c del @path"

Forfiles documentation:

And cron for windows:

share|improve this answer
Is there a way to do it with deleting files older than X days? – Nick Anderegg Aug 6 '12 at 17:36
@NickAnderegg I updated my answer. – Sandro Dzneladze Aug 6 '12 at 17:42
I think this will work, thanks! – Nick Anderegg Aug 6 '12 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .