1. From the Start Menu, search for and open Notepad.
  2. Paste this script into Notepad once it's open:
REM Remove files older than 30 days forfiles /p "C:\Users\YOURUSERNAME\Downloads" /s /m *.* /c "cmd /c Del @path" /d -30 	

Replace YOURUSERNAMEwith the username listed in the path on your computer.

  • Hit Cntrl+S to save the file, and save it as .bat in a safe location.
  • Test the batch file by launching it, and opening your Recycle Bin to see that any file older than 30 days has just been deleted.
  • Now, to automate the batch file launching so you don't have to launch it manually, click the Start Menu and type in "Task Scheduler". Open the program.
  • From the menu, navigate to Action > Create Basic Task
  • Give the task a name and description in the window that appears.
  • On the next step,"Trigger" will be highlighted in the left menu. Select whether you want the task to initiate daily, weekly, monthly, and so on.
  • Select your time preferences.
  • When the "Actions" preferences appear, select "start a program"
  • Click the browse button, and navigate to the batch file you created before and select it.
  • On the last screen, you'll see an overview of what you've just created. Click "Finish".

Share This Story

Get our newsletter