As we know, Windows 10 has a feature called Storage Sense. The function of the Storage Sense is to free up space on your computer, mainly the temporary files and the Recycle Bin content. Usually, it deletes files that are in Recycle Bin, or the unused temp files older than a month or, to be precise, 30 days. The feature is useful, but it doesn’t let you add additional folders to it. This is because other files may have vital information which should not be d. If you want to automatically delete files older than X days, where X is any number of days you choose at your own discretion, then you need to create a scheduled task and use a command prompt command.

We should warn you that the command used to automatically delete files older than X days doesn’t stop to check if you accessed the file recently. It will look at the ‘Last Modified’ date so if the file was never modified then it will be deleted.

Steps To Automatically Delete Files Older Than X Days On Windows 10

1. Right click on the Start Menu and go to Command Prompt (Admin) to open the Elevated Command Prompt.

select user

2. To delete files from a certain location, copy and paste the following

For example,

Files /p “C:\path to folder” /s /d -30 /c “cmd /c del @file”

Files /p “C:\Users\Nick\Desktop\Screenshots” /s /d -10 /c “cmd /c del @file”

There are some important warnings you have to keep in mind. The first one is that the location should be entered very carefully. If you make a mistake in typing the folder name or for the worse the drive name, then a mishap will happen. So, to avoid this, you should practice the process by operating on a dummy folder. Then choose the location of that folder and put in the command prompt command. Now that you are well accustomed, you can operate on the original files location.

select user

To delete files created before a certain number of days, automatically, choose the number of days by editing the number field. For example, if you want to delete all folders before 10 days, then change the number field to -10.
That’s all!


Happiness is that best therapy. Use it to heal yourself and then others!


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.