Windows: If you download files you only need once or twice and then forget about, you downloads folder can get cluttered. Use this batch file to automatically delete those files on a schedule.
Many of us forget to manually clean out our downloads folder, and those forgotten files can take up a lot of space. If all you need to keep clean is your downloads folder, this simple batch script does the job.
How-To Geek shares the following script to automatically delete files that are older than 30 days from the downloads folder:
- From the Start Menu, search for and open Notepad.
- Paste this script into Notepad once it’s open:
REM Remove files older than 30 days forfiles /p "C:UsersYOURUSERNAMEDownloads" /s /m *.* /c "cmd /c Del @path" /d -30<br>
YOURUSERNAME with 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”.
Now the batch file will launch according to the preferences you selected in “Task Scheduler”, sending your old files in your Downloads folder to your Recycle Bin.