- @Echo off
- :: User Variables
- :: Set this to the number of folders you want to keep
- Set _NumtoKeep=1
- :: Set this to the folder that contains the folders to check and delete
- Set _Path=D:\CCTV\CAM
- :: Set this to the number of cameras
- Set _NumCam=10
- For /l %%i In (1,1,%_NumCam%) Do (
- PushD %_Path%%%i
- Set _rdflag= /q
- For /F "tokens=* skip=%_NumtoKeep%" %%I In ('dir "%_Path%%%i" /AD /B /O-D /TW') Do (
- rd /s /q %%~fI
- )
- PopD
- )
複製代碼 Save this as a bat file and create a schedule job to run it everyday |