Windows bat batch deletes files that are specified n days ago

Source: Internet
Author: User
Tags windows support

Windows under Bat batch, automatically gets the last modification time of the file, and then deletes the file number of days before the specified date, requires Windows Support Forfiles command, XP and the above system with forfiles command.

Deletes a file 7 days before the specified directory (directory is C:\test):

forfiles/p "C:\Test" /s/m *.*/d-7/C "cmd/c del @path"

Delete files in the current directory of the batch file 7 days ago:

forfiles/p %~dp0 /s/m *.*/d-7/C "cmd/c del @path"

Copy one of the above, create a new text file, paste and save in bat format, run regularly or join a scheduled task.


Displays the path of the file seven days before the current directory

forfiles/p%cd%/s/m *.*/d-7/C "cmd/c echo @path"

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.