Automatically delete the batch processing of files in the specified folder n days ago

Source: Internet
Author: User
@ Echo offif not exist D: \ delfiles goto eofrem defines the folder 'array' set folders [0] = folder1set folders [1] = folder2set folders [2] = folder3rem if D: \ delfiles: to change the folder, modify the above 'array' set SDAY =-3rem to delete the files created on SDAY day under D: \ delfiles, to modify the number of days, modify the above sdayforfiles/p D: \ delfiles/d % SDAY %/S/C "CMD/C del @ path/Q" REM loop Delete the folder created in the above 'array' folder SDAY days ago REM if the directory does not exist, forfiles will be skipped and an error will be returned: the specified directory does not exist for/F "tokens = 2 delims =" % s in ('set folders [') do (forfiles/p D: \ delfiles \ % S/D % SDAY %/S/C "CMD/C if @ isdir = true echo RD/S/Q @ file & RD/S/Q @ file ") exit: eofexit

In some cases, batch processing is quite appropriate, such as scanning folders in the company, which is simple and practical.


Reference Source:

Http://superuser.com/questions/191224/populating-array-in-dos-batch-script


This article is from the "temporary blog" blog, please be sure to keep this source http://gzzhang.blog.51cto.com/5312382/1546852

Automatically delete the batch processing of files in the specified folder n days ago

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.