Automatically Clear Your Downloads Folder With A Batch Script

Automatically Clear Your Downloads Folder With A Batch Script

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:

  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:UsersYOURUSERNAMEDownloads" /s /m *.* /c "cmd /c Del @path" /d -30<br>

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

How to Automatically Delete Files in Your Download Folder on a Schedule [How-To Geek]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


One response to “Automatically Clear Your Downloads Folder With A Batch Script”