Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
possibly duplicate stackoverflow.com/questions/51054/… –  Siva Charan Feb 10 '12 at 16:52
    
also: serverfault.com/questions/49614/delete-files-older-than-x-days (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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.