SEARCH

How-To Geek

How to Automatically Delete Files in Your Download Folder on a Schedule

Delete 0

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

sshot-1

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.

sshot-2

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.”

sshot-3

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.”

sshot-4

From the “Trigger” section, we will choose to make the task a weekly action followed by pressing “Next.”

sshot-5

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.

sshot-6

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.”

sshot-7

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.”

sshot-8

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.

sshot-9

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

Martin Hendrikx is a technology writer and author with years of experience. He has traveled to 47 countries and counting and is well versed in all things Windows.

  • Published 11/12/14

Enter Your Email Here to Get Access for Free:

Go check your email!