Alternatively, you can type the date related parameter and enter a colon character :. This will make File Explorer show the date picker. Pick a date or condition from the calendar pop-up. You can click on a date and drag to specify a date range.
This way you can filter the results to get exactly what you want. This method is good for deleting files manually once in a while. If you need to automate the procedure, e. Let's review them.
This command selects a file or a set of files and executes a command on that file. For example, means over a year ago, means a month ago. Command strings should be wrapped in double quotes. The following variables can be used in the command string: file - returns the name of the file.
Substitute the folder path and the amount of days with desired values and you are done. For example, to remove the files older than a month from the Downloads folder, use the following command:. This trick works in all modern versions of Windows including Windows 7, Windows 8, Windows 8. If the Get-ChildItem cmdlet finds any files that are older than a month, then the Remove-Item cmdlet will be called for each file to remove it.
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:. If you like this article, please share it using the buttons below.
It won't take a lot from you, but it will help us grow. Thanks for your support! Sergey Tkachenko is a software developer from Russia who started Winaero back in Hi Kenone, thank you for your response. I ran the batch file at the DOS prompt and the "forfiles" command is not recognized.
I received the below error message; 'forfiles' is not recognized as an internal or external command,operable program or batch file. I've never used it so be careful. I did that so long ago that I forgot that I had done it. If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem.
Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended. Please note: Do not post advertisements, offensive material, profanity, or personal attacks. Please remember to be considerate of other members. All submitted content is subject to our Terms Of Use. This will run on a schedule and will not require human interaction to input any data. My problem is, I am not good at writing batch files.
I can do the basic type stuff, but finding dates and doing date comparison is beyond me. In fact, we will delete files on specific folders. For example, we will tell the batch file to delete. Create a text file and copy the below command line :. As a result, we will tell the cmd remove all files in folder that are located in the Test folder.
Also, you can use Task Scheduler to create scheduled task. Batch to delete file. Batch to delete all files.
0コメント