@ 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