Windows 10 has a feature to automatically clean up files older than 30 days from the Downloads folder and Recycle Bin. What if you want to do the same thing on other versions of Windows? Or maybe you want files to be automatically deleted from other folders and older than a different time period? Why is it older than 30 days? In today’s article, we will look at how to set up automatic deletion of files from a folder of your choice older than the number of days you specify.
1. Open the “Notepad” application: you can find it through the search bar or go to the “Start” menu => “All applications” => “Accessories” => “Notepad”. Insert the following text:
REM Remove files older than 20 days ForFiles / p "C: UsersASDownloads " / s / d -20% / c "cmd / c del @file"
Change the highlighted in red to your own, in the example I indicate that files older than 20 days should be deleted from the Downloads folder of the user “Lili”. You can specify any other folder and instead of 20 put 10 or 30 days (as long as you want).
2. Go to “File” and select “Save As” => select a location to save (the main thing is that no one deletes it in that place), name the file whatever you want and in the “File name” field after the dot, write bat instead of txt (as shown on the image).
3. Open the task scheduler: in the search bar or in the run menu (run by pressing Win + R) enter the command taskschd.msc and press the Enter key.
4. Go to Action and select Create Simple Task.
5. Come up with a name for the task and write it in the “Name” field, then click “Next”.
6. Select how often you want to start cleaning the specified folder from files older than the specified number of days and click “Next”.
7. Choose from what day and time to start cleaning, and when to repeat it, click “Next”.
8. Put a full stop in front of “Run the program” and click “Next”.
9. Click on “Browse” and select the file that you created in the second paragraph, then click “Next”.
10… The last window shows all the options you have selected, click “Finish”.
Now, every time a task you have created is launched, files older than the time you specified will be deleted in the folder (which you specified in the first paragraph).
That’s all for today, if you know other methods – write in the comments! Good luck ?