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 want to make a scheduled process in Windows (specifically, Windows 7) that every 3 hours will delete all the files in all folders older than 24 hours (like the Unix find's -mtime +1). Basically the Windows equivalent of having this configured in my Unix cron:

find $TRANSITDIR -mtime +1 -exec rm -rf {} \;

Although I seem to have found that the Windows cron equivalent is the scheduler, I just don't know the Windows commands to do that.

Does anyone have a scheduler script ready-to-go?

share|improve this question

migrated from serverfault.com Jul 29 '11 at 15:43

This question came from our site for system and network administrators.

Related: superuser.com/q/434626/108226. The solution I posted (using PowerShell) can be fairly easily modified to work on any folder or drive, not just the recycle bin, and can be scheduled using the Task Scheduler GUI or the command-line schtasks.exe. –  Indrek Nov 5 '12 at 21:28

1 Answer 1

Not exactly what you want to do, but I'd say that the automatic clearings of ccleaner are worth to take in consideration when talking about windows. I use it to find and clean tmp files for windows machines.

It has a limited CLI http://www.piriform.com/docs/ccleaner/advanced-usage/command-line-parameters#Command-line_parameters_for_CCleaner_

Also provided that you're a shell guy and you said you need it for W7, you can try powershell:


share|improve this answer

Your Answer


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.