First of all, similar to how often to run the batch processing, it is set in the task schedule.
Run this batch processing in the task schedule:
for /f "skip=5 tokens=1,2,3,4,5,7* delims=-:/ " %%i in ('dir "path" /a:-d /t:c') do if not "%%m" == "" if "%%i%%j%%k%%l%%m" gtr "time1" if "%%i%%j%%k%%l%%m" lss "time2" @del "path\%%n%%o" /a /f /q>nul 2>nul
Among them:
1. Path refers to the directory to be operated, for example
d:\video recording materials
2. Time is the comparison time. For example, taking
October 12, 2009 09:13 as the dividing point, it is written as
200910120913, where: time1 is the start of the time period, time2 is the end of the time period, and this batch processing will delete all files created between this time period.
3. This batch processing can only process
one directory (folder) at a time and does not process its
subdirectories (folders).
4. This batch processing depends on the output format of dir, so please test the dir command output before running to see if it meets the requirements of this batch processing. Run
dir "path" /a:-d /t:c in cmd
See if the output is like the following example.
Volume in drive C has no label.
Volume Serial Number is 303A-5C0B
Directory of C:\Documents and Settings\Hanye Guxing
2009-10-12 09:13 2,883,584 NTUSER.DAT
2009-10-12 09:13 24,576 ntuser.dat.LOG
2009-10-12 09:13 178 ntuser.ini
2009-10-12 21:48 976 ntuser.pol
4 File(s) 2,909,314 bytes
0 Dir(s) 12,642,504,704 bytes free
If you only want to delete files before a certain time point, you can write it like this:
for /f "skip=5 tokens=1,2,3,4,5,7* delims=-:/ " %%i in ('dir "path" /a:-d /t:c') do if not "%%m" == "" if "%%i%%j%%k%%l%%m" lss "time" @del "path\%%n%%o" /a /f /q>nul 2>nul
[
Last edited by Hanyeguxing on 2009-12-16 at 19:54 ]