Server is Windows Server 2012
Put it in the head office room to pick up the data.
But the disk that saves the data is not cleaned up for a while and will be full.
and can only manually clean up a directory at a time, because there are too many files, a clean-up, the disk is stuck.
This is the directory structure. Scan_bak is the total directory, the following is the date directory. There are many txt files inside.
E:\server\Remote\scan_bak
->20150921
->cn_343u098097fiyf544fdlf.txt
The main is to delete the date folder, keep the last 7 days of the directory.
Every manual cleanup is too much trouble. So I wrote a bat file.
The contents are as follows:
echo "#############################" >> E:\cmd\clean_scan_bak_log.txt
echo Start time:%date%_%time% >> E:\cmd\clean_scan_bak_log.txt
forfiles/p "E:\server\Remote\scan_bak"/s/m * */d-7/C "cmd/c del @path"
dir/ad/b/s E:\server\Remote\scan_bak\ |sort/r >e:\cmd\clean_scan_bak_kill.txt
for/f "tokens=*"%%i in (E:\cmd\clean_scan_bak_kill.txt) do rd "%%i"
Del E:\cmd\clean_scan_bak_kill.txt
echo Completion time:%date%_%time% >> E:\cmd\clean_scan_bak_log.txt
Then set the task schedule
View the log file with the following contents:
"#############################"
Start Time: 2015/09/21 Monday _ 0:00:00.74
completion time: 2015/09/21-Monday _ 1:13:44.66
This article is from the "Falling Star" blog, make sure to keep this source http://xiao987334176.blog.51cto.com/2202382/1697134
Windows automatically deletes files for 7 days