Windows forfiles (Delete history files)

Source: Internet
Author: User

Introduction

Forfiles is a batch delete command that comes with Windows, it is a good choice to judge the history file by using it to judge the time by the modification Date property of the file itself.

Grammar

forfiles [/P Path] [/M searchmask] [/s] [/C Command] [/d [{+ |-}] [{mm/dd/yyyy | DD}]]

[/P Path]: Specifies the path, of course, the directory can be used "." [/M Searchmask]: Search By default is *. * [/s]: Traverse subdirectories for search, including current directory [/d [{+ |-}] [{mm/dd/yyyy | DD}]]: Select a file with a date greater than or equal to (+) (or less than or equal to (-)) specified date, default +where mm/DD/YYYY is the specified date, DD is the current date minus DD days, and the default is DD. The effective range of DD is 0-32768For example:/D- the: Find files up to 15 days ago/d ./ A/9: Specifies that the found file date is 2016/ A/9[/C Command]: Specifies the command to execute in the format [/C"cmd/c rd/s/q @path"]; double quotes inside the/c followed by the command to be executed. Variable: @file display file name @fname displays a file name with no extension @ext displays the full path to the file extension @path the relative path of the @relpath file @isdir if the file type is a directory, evaluates to True, otherwise the value is False@fsize Displays the file size in bytes @fdate display the last modified date stamp in the file @ftime display the last modified timestamp in the file
Example

1. Lookfor files or folders with the name "--" in the "D:\ Backup \ Data" directoryand the modification time greater than 15 days

forfiles.exe/p d:\backup\data/m *-*-*/d-"cmd/c echo @path"

2. Delete,/s/q (the file is also deleted under the/S folder,/q Force Delete is not prompted)

forfiles.exe/p d:\backup\data/m *-*-*/d-"cmd/c rd/s/q @path"

Note: path does not support "\\url\" This shared path, RD (delete folder), Del (delete file)

Summary

Note:

pursuer.chen

Blog:http://www.cnblogs.com/chenmh

This site all the essays are original, welcome to reprint, but reprint must indicate the source of the article, and at the beginning of the article clearly give the link.

Welcome to the exchange of discussions

Windows forfiles (Delete history files)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.