How Does Windows Automatically Delete Files Older Than X Days?

How does Windows automatically delete files older than X days? Don’t worry; this post can give you some help in batch file delete folders older than x days.


By Lora / Updated on April 3, 2024

Share this: instagram reddit

How do you automatically delete a folder after a time interval?

When using the computer, tons of data will be created every moment. People use various apps to create and edit documents, sheets, images, videos, etc.

To ensure a smooth performance of the device, users sometimes delete their old or unwanted files to free some space for the computer. Thus the machine can normally work as usual.

Those who back up their hard drives can feel more pain in this issue. They need methods to automatically remove older backups urgently.

But manually deleting old files will be laborious and time-wasting. So many users are wondering whether they can delete files older than 30 days or however they like.


File deletion older than "X" days


Good Morning; I need to delete files older than "X" days. Is there a program scheduler to delete, move, and copy files older than X days? Thanks for your help.


- Question from QNAP


If you are in the same plight and need to know “how does Windows automatically delete files older than X days”, this article can offer some help.

On the other hand, even if you repent your deletion, you can get help to recover them without difficulties.

How does Windows automatically delete files older than X days?

Three methods can help you remove whatever you don’t want on your drives.

Method 1. Delete files older than 30 days or as you like via the forfiles command

Command Prompt can help you batch file delete folders older than x days. It uses parameters and commands to implement your operations.

Some users will use the Recover command in CMD to restore data from corrupted or damaged hard drives.

Here we could utilize the “forfiles” command to select and manage a bunch of files. Its command syntax goes like this:

forfiles [/P pathname] [/M searchmask] [/S] [/C command] [/D [+ | -] [{date|days }]]

And you may learn what the parameters stand for:

/P the path you could like to start the search
/S search in subdirectories
/C run the command on each file
/D specify the date you last modified the file

Now follow the steps to remove files in batch.

Step 1. Start Command Prompt by searching for it in the search box > run as administrator.


Step 2. Input forfiles [/P pathname] [/M searchmask] [/S] [/C command] [/D [+ | -] [{ | }]]

For example, forfiles /p “E:\minecraft screenshots” /s /d -30 /c del

Thus, you could delete the chosen files older than 30 days.


You could change the parameters according to your specific needs.

Method 2. Use the Task Scheduler to delete files automatically

How does Windows automatically delete files older than X days? Except for commands, you could also utilize the Task Scheduler.

Some users have reported that the recycle bin deleted files automatically, and they don’t know where to find them back. It means that this tool can help users remove what they don’t want automatically.

Now learn how does windows scheduled task delete files older than X days.

Please note that this tool will also utilize the forfiles commands.

Step 1. Start Task Scheduler by searching for it in the search box > Create Task.


Step 2. Specify the task name as you like in General > Triggers > New.


Step 3. On a schedule > specify the intermittent according to your needs > OK.


Step 4. Actions > New.


Step 5. Start a program > input C:\Windows\System32\ForFiles.exe in the Program > input /p "%userprofile%\Documents" /s /d -30 /c "cmd /c del @file" in Add arguments. Here we take the Downloads folder as an example; please choose your target folder.


If Task Scheduler not shows all tasks or work properly, please get some help to fix it.

Method 3. Enable the Storage Sense

How to delete files older than 30 days automatically? Storage Sense would be of some help as well. Once enabled, it cleans up the unwanted files in the Recycle Bin or the temporary files to keep your storage space sufficient.

Those users who have found Recycle Bin deleted files automatically may have activated this feature.


Step 1. Click Start menu > Windows Settings > System.


Step 2. Click Storage > Configure Storage Sense or run it now.


Step 3. Switch on > Delete files in my recycle bin if they have been there for over X days.


Thus to deleted files older than 30 days or as you like.

How to recover deleted files if you repent?

Tools like Storage Sense or commands cannot tell which file is essential and better not to be deleted. You need to be careful and ensure you won’t delete what is still in use.

But what if the essential files have been removed already? How to recover files after deletion?

For efficiency, you might as well choose MyRecover – the efficient Windows data recovery app to help you out.

It is specially designed for Windows users, facilitating them to scan and recover deleted and missing files. It provides simple and speedy data recovery. It is also sophisticated and efficient in a variety of ways.

  • Efficient. Support for more than 200 recoverable data types, including images, movies, documents, spreadsheets, zip files, and so on.
  • Comprehensive. Selectively restore deleted and lost files from HDD, SSD, USB, or SD card, etc.
  • Convenient. Files that have been deleted can retain their original filenames, formats, folders, and quality.
  • Compatible. Support for Windows 11/10/8/7 SP 1 & Server, as well as NTFS/exFAT/FAT32/ReFS, and so on.
Download SoftwareWin 11/10/8/7/Server
Secure Download

Step 1. Install and run the software > Hover the mouse over the drive saved deleted files before, and click Scan.


Step 2. Filters like Type, Size, Path, etc., can help you locate the target files much faster. If you can recall the filenames or the type, you could input the names or the extensions to find them.


Step 3. Choose Deleted files/Recycle Bin > select what your need > click Recover x files. If no wanted files were found, go to Other missing files > select specific types to retrieve.


Also, navigate to the desktop folder; you could recover files automatically deleted from the desktop.

To sum up

How does Windows automatically delete files older than X days? Users who want to batch file delete folders older than x days can refer to this article and get some help.

The Task Scheduler, Command Prompt, and Storage Sense could be of some help.

In addition, if you have repented or need to recover deleted files from the hard drive, you can choose MyRecover – the professional data recovery app for Windows to help you.

Lora · Editor
Lora is an editor of AOMEI Technology. She is also a tester and editor of AOMEI Data Recovery Tools. -- "Keep testing, write the most useful tutorials for helping people recover the lost data for Windows and phones" is the most meaningful thing for her. Dedicated to creating helpful tutorials, she hopes her tutorial can assist users to effortlessly solve data loss problems on their personal computers and mobile phones.