Automatically delete old files from folder on schedule

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 ?

Related Posts

Property Management in Dubai: Effective Rental Strategies and Choosing a Management Company

“Property Management in Dubai: Effective Rental Strategies and Choosing a Management Company” In Dubai, one of the most dynamically developing regions in the world, the real estate…

In Poland, an 18-year-old Ukrainian ran away from the police and died in an accident, – media

The guy crashed into a roadside pole at high speed. In Poland, an 18-year-old Ukrainian ran away from the police and died in an accident / illustrative…

NATO saw no signs that the Russian Federation was planning an attack on one of the Alliance countries

Bauer recalled that according to Article 3 of the NATO treaty, every country must be able to defend itself. Rob Bauer commented on concerns that Russia is…

The Russian Federation has modernized the Kh-101 missile, doubling its warhead, analysts

The installation of an additional warhead in addition to the conventional high-explosive fragmentation one occurred due to a reduction in the size of the fuel tank. The…

Four people killed by storm in European holiday destinations

The deaths come amid warnings of high winds and rain thanks to Storm Nelson. Rescuers discovered bodies in two separate incidents / photo ua.depositphotos.com Four people, including…

Egg baba: a centuries-old recipe of 24 yolks for Catholic Easter

They like to put it in the Easter basket in Poland. However, many countries have their own variations of “bab”. The woman’s original recipe is associated with…

Leave a Reply

Your email address will not be published. Required fields are marked *