How to delete files older than 30 days on Windows 10


Microsoft introduces and adds options on Windows 10 Redstone 4 that automatically clean the Downloads and Recycle Bin folders at regular intervals. But what if the user wants to delete files from other folders? This article will guide you Taimienphi.vn delete files older than 30 days on Windows 10.


Luckily, you can use Windows built-in tools to delete files older than 30 days in other folders.

Basically, the commands that Taimienphi.vn introduced below will help you create scripts (BAT files) to automatically search for old files and delete those files. Instead of having to download optimal system software, you can use it .BAT file to clean the computer.

All you need to know is which folder you want to clean up, delete old files, and Admin privileges are needed, although in most cases a standard user account can run these commands well.

For users who want to clean up folders, like the Downloads folder, a script can be used to automatically clean up the books in the directory. In addition to the large network administrators and system administrators, this script is extremely useful, helping them clean the directory without having to use third party software.

When to use the script? This depends on how often you want to delete items from the folder. For example, if you want to delete items more than 30 days in the Downloads folder, you can run the script once a month.

To create the script delete files older than 30 days on Windows 10 Within the directories, we will use the ForFiles command tool, designed to manage specific files from the command line.

In this tutorial, Taimienphi.vn uses the default Downloads folder on Windows 10 inside C: Users Username Downloads, and delete items for 30 days, but you can change these settings if desired.

How to delete files older than 30 days on Windows 10

Step 1: Open Command Prompt / Windows PowerShell under Admin. To do this, enter Command Prompt / Windows PowerShell In the Search box on the Start Menu, on the list of search results, right-click and select Run as Administrator.

Step 2: Enter the following command in the Command Prompt / Windows PowerShell window:

ForFiles / p “C: Users Username Downloads” / s / d -30 / c “cmd / c del @file”

Note in the above command you can replace C: Users Username Downloads by the directory you want to clean up and -30 by the number of days you want to delete the item.

Meaning of the parameters in the above command:

/ p: represents the directory path you want ForFiles to look for files older than the specified number of days.
/S: means ForFiles will apply removal rules in subdirectories, if any.
/ d: day index, in the example above is 30 days.
/ c: Send ForFiles command to execute the task.
del stands for delete, ie delete.
@file represents the filename and in this command it applies to all files.

Running the command to delete files older than 30 days on Windows 10 is not too difficult, only that the user will have to manually enter the path each time to delete the items in the folder. However you can simplify this.

Navigate to the folder you want to clean and open that folder, press Shift key And right click on the folder. Click on the option Open PowerShell window here (or Open Command Prompt window here if using an older version of Windows) and enter the following command:

How to delete files over 30 immediately on Windows 10 2

ForFiles / s / d -30 / c “cmd / c del @file”

In this example, the parameter / p (short for path means path) is deleted because we have opened the folder to be deleted.

There are also a number of other ways to automate the cleaning of each directory, using the .BAT file that contains the following commands:

@echo off

ForFiles / s / d -30 / c “cmd / c del @file”

End

How to delete files over 30 immediately on Windows 10 3

With this script, all files that are over 30 days old (including scripts) will be deleted when running the BAT file.

https://thuthuat.taimienphi.vn/cach-xoa-cac-file-qua-30-ay-tren-windows-10-31412n.aspx
So above Taimienphi.vn has just taught you how to delete files over 30 days on Windows 10. With this tip, you can easily speed up your computer, improve Windows performance in a moment. If you have any questions or need any answers, please leave your questions in the comment section below the article, Taimienphi.vn will answer your questions as soon as possible.

.

Add a Comment

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