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'm looking for a function in batch that recursive delets all files/folders older than X Days from a given path.

Is there a Fast and easy snippet that could be placed in a batch function?

share|improve this question
possibly duplicate… – Siva Charan Feb 10 '12 at 16:52
also: (maybe we need one of those on SU as well...) – Oliver Salzburg Feb 10 '12 at 17:04
hmm on serverfault these are not really batch. stackoverflow are nor running for me atm. but I need to figure out the problem ... – VZn Feb 20 '12 at 1:20

If your command interpreter is JP Software's TCC/LE, simply use date ranges and the del command. Here's how to delete files (and consequent empty directories) older than 30 days:

del /[d-30,%@makedate[0]] /s/x *
The * is a wildcard, of course, and can include a pathname.

Further reading

share|improve this answer
I can only use the standard Windows batch interpreter. – VZn Feb 13 '12 at 2:12

You must log in to answer this question.

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