4 Ways to Delete Files Older Than a Certain Number of Days on Windows

Want to delete the pictures you saved a few days ago? Or, perhaps you want to remove the files you downloaded last week.


Whatever the case may be, we’ve got you covered. In this article, we’ll explore different ways to delete files from a specific date, be it a day, a week, a month, or even a year ago.


1. Use File Explorer

There’s no denying that File Explorer is one of the best file management tools for Windows. So, let’s check out how this tool can help you delete specific files:

  1. Press Win + E to open File Explorer.
  2. Navigate to the folder containing your files. In this example, we’ll navigate to the Downloads folder.
  3. Type datemodified: in the File Explorer search bar. This should display the “Search” tab in the top-left corner.
  4. Scroll to the Search tab, click the Date modified drop-down menu, and then select your preferred option.

Finally, select the files you don’t need and then press the Delete key.

Alternatively, you can search for your files using a specific date. For example, here’s how to search for files that were modified on a certain day:

  1. Navigate to the folder containing the files you want to delete.
  2. Type datemodified:28/08/2022 in the File Explorer search bar. However, replace “28/08/2022” with your preferred date.

Finally, select and delete the files you don’t need.

To pick a date range, follow these steps:

  1. Open the folder containing the files you want to delete.
  2. Type datemodified:28/08/2022 .. 31/08/2022 in the File Explorer search bar, but replace “28/08/2022 .. 31/08/2022” with your preferred date range.
  3. Select the relevant files and delete them.

To search for your files based on the date they were created, follow these steps:

  1. Navigate to the folder containing your files.
  2. Type datecreated:22/09/2022 in the File Explorer search bar, but replace “22/09/2022” with your preferred date.

To pick a date range for the “date created” option, follow these steps:

  1. Open the target folder containing your files.
  2. Type datecreated:15/09/2022 .. 22/09/2022 and replace “15/09/2022 .. 22/09/2022” with your preferred date range.
  3. Select the relevant files and delete them.

2. Use the Command Prompt

The Command Prompt is a powerful tool that you can use for various purposes. For example, you can use it to tweak the system settings or run various apps.

Interestingly, the Command Prompt can also help you remove files on Windows. So, let’s see how you can delete your old files using this tool:

  1. Type Command Prompt in the Start menu search bar.
  2. Right-click on the Best match result and select Run as administrator.
  3. Type the following command:

ForFiles /p "C:\Target_Folder" /s /d -Number_of_Days /c "cmd /c del @file"

Replace the C:\Target_Folder with the correct folder path. From there, replace the Number_of_Days command with the number of days in which the files were last modified.

Here’s how you can find your folder path:

  1. Press Win + E to open File Explorer.
  2. Navigate to the folder containing the files you want to delete. In this example, we’ll navigate to the Downloads folder.
  3. Type CMD in File Explorer’s address bar and press Enter. This should open a Command Prompt window.
  4. Select the folder path displayed and press Ctrl + C to copy it. In this example, the folder path is C:\Users\tladi\Downloads.

You now have your folder path.

So, you can now decide on the files you want to delete. For example, let’s say you pick files that were last modified 14 days ago.

With all the details you currently have, here’s what your command should look like:

ForFiles /p "C:\Users\tladi\Downloads" /s /d -14 /c "cmd /c del @file"

After entering all the details in your command, press Enter to start deleting your files.

3. Use the Task Scheduler

You can also delete your files by using the Task Scheduler. Here are the steps you need to follow:

  1. Type Task Scheduler in the Start menu search bar and select the Best match.
  2. Right-click on the Task Scheduler Library option in the top-left corner and select New Folder.
  3. Name the folder as Delete Old Files or something similar.
  4. Press OK to save these changes.

Right-click on the Delete Old Files folder and select Create Task. This should take you to the “General” tab on the “Create Task” window.

Specify the task name in the “Name” box. For example, you can name the task as Delete Old Files in the Downloads Folder.

From there, scroll down and select the Run whether user is logged on or not option. Next, click the Configure for drop-down menu and select the relevant option.

From there, scroll to the Triggers tab and press the New button at the bottom. This should display the “New Trigger” window.

Follow these steps once you’re on the “New Trigger” window:

  1. Click the Begin the task drop-down menu and select On a schedule.
  2. Select whether you want to run the task once, daily, weekly, or monthly by picking the relevant option in the top-left corner.
  3. Press OK to save these changes. This should take you back to the “Triggers” tab.

Navigate to the Actions tab and press the New button at the bottom. This should display the “New Action” window.

Follow these steps when you’re on the “New Action” window:

  1. Type ForFiles.exe in the Program/script box.
  2. Type the following command in the Add arguments box:

/p "%userprofile%\Target_Folder" /s /d -Number_of_Days /c "cmd /c del @file"

Replace the Number_of_Days command with the number of days in which the files were last modified. For example, you can pick 21 if you want files that were last modified three weeks ago.

From there, replace the Target_Folder command with the correct folder path. For example, if your original folder path is C:\Users\tladi\Downloads, then you should replace Target_Folder with Users\tladi\Downloads.

By now, you have all the information you need. So, you should have ForFiles.exe in the “Program/script” box and the following command in the “Add arguments” section:

/p "%userprofile%\Users\tladi\Downloads" /s /d -21 /c "cmd /c del @file"

Press the OK button after entering the details.

Now, your files should be deleted automatically using the task you’ve created. To get rid of this task at a later stage, open the Task Scheduler and remove the Delete Old Files folder.

4. Use the System Settings

Want to automatically delete old files from the Recycle Bin or the Downloads folder? The system settings can help.

Here are the steps you need to follow:

  1. Type Settings in the Start menu search bar and select the Best match.
  2. Select System from the options.
  3. Click Storage on the left and then select Configure Storage Sense or run it now on the right-hand side.
  4. Click the Delete files in my Downloads folder if they haven’t been opened for more than drop-down menu.
  5. Select 1, 14, 30, or 60 days from the options.

Next, click the Delete files in my Recycle Bin if they have been there for drop-down menu and configure the settings to your liking.

Finally, close the settings windows and restart your device to save these changes.

Delete Any File on Your Windows Device, Hassle-Free

Deleting files on Windows is quite easy. But sometimes, you just want to delete files using a specific date range.

So, if you need to delete files older than a certain number of days, try the solutions we’ve covered. And if those files refuse to leave your device, there are solutions for that too.

Leave a Reply

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