Whether you share your computer with other people or you use it for a lot of downloads, it is nice to be able to clear out the download folder without having to manually take care of it each week or month, which is when an automated deletion comes in handy.
You can automate the cleanup of your download folder using a batch file that will delete files older than a certain amount of days. You can run this whenever you feel that you need to clean up your download folder or you can use the Task Scheduler to run it daily, weekly, monthly, etc.
Create Your Batch File
For this example, we will tell the batch file to delete any files that are located in the download folder that are older than 30 days. This is useful if you do things like Photoshop work, or writing where you download a lot of resources that you don’t need after an extended period of time.
The first step will be to open notepad. Once you have the program open, paste this string into the screen.
REM Remove files older than 30 days forfiles /p "C:\Users\YOURUSERNAME\Downloads" /s /m *.* /c "cmd /c Del @path" /d -30
Remember to change the directory to match your computer. You can also choose any directory that is on your computer for the target. Once you have entered the string, save the document as a batch file.
Simply run the file to make sure it works and you will see that any files in your download folder are automatically sent to your Recycle Bin if they are older than 30 days.
Create a Scheduled Task
For the purpose of this example, we will schedule the automatic file deletion every seven days. Begin by opening the start menu and typing in “Task Scheduler” then running the application.
Alternatively, you can open your “Control Panel.” Under the “System and Security” section select the “Administrative Tools” option and then run the “Task Scheduler.”
Once you have the program open, click on the “Action” drop-down menu and select “Create Basic Task.”
You can give the task a name and description of your choosing. For this example, we will call it “Weekly Download Cleanup” and leave the description empty since the title is self-explanatory; then click “Next.”
From the “Trigger” section, we will choose to make the task a weekly action followed by pressing “Next.”
Now you will need to select a time and day. Remember to choose a time and day that your computer is powered on. For this example, we will just choose midnight on Friday then click next.
Now you will see the “Action” screen. We will leave this as is, since we want to run a specific program every Friday; so you can just click “Next.”
Now you will just need to click on “Browse” and select the batch file you created. As you can see, our batch file was saved on the desktop and is called “DownloadCleanup.bat.” Once you have done that, just click “Next.”
The last screen you will see gives you a comprehensive overview of the task you created. Once you verify that everything is right, just click “Finish” to complete the task creation and it will run automatically according to your specifications.
Now that you know how to schedule auto-deletion of your old files, you don’t need to worry about how to clear up any old files from your download folder.
Image Credit: Mixy Lorenzo on Flickr