本帖最后由 netmaple 于 2019-10-11 18:26 编辑 #include <File.au3>
Local $aFile, $nMax = IniRead(@WorkingDir & '\配置文件.ini', '配置', '数量', '')
Local $sWNList = IniRead(@WorkingDir & '\配置文件.ini', '配置', '白名单', '')
Local $nNow, $ExitFlag
Local $hTimer = TimerInit()
;~ Local $sPath = @DesktopDir & '\if\BackUp'
Local $sPath = IniRead(@WorkingDir & '\配置文件.ini', '配置', '路径', '')
Local $s_WNList = StringRegExpReplace($sWNList, '[.+\-(){}[\]^$]', '\\$0')
While 1
$aFile = _FileListToArray($sPath)
If Not @error Then
If $aFile[0] > $nMax Then
$nNow = 0
For $ii = 1 To $aFile[0]
If Not StringRegExp($aFile[$ii], '(?:' & $s_WNList & ')') Then
$nNow += 1
If $nNow > $nMax Then
$ExitFlag = 1
MsgBox(64, '超出', '当前已超出,删除:' & $sPath & '\' & $aFile[$ii])
;~ FileDelete($sPath & '\' & $aFile[$ii]) ;删除
EndIf
EndIf
Next
If $ExitFlag Then
MsgBox(0, '', '删除完毕,退出')
ExitLoop
EndIf
EndIf
EndIf
If TimerDiff($hTimer) >= 60000 * 3 Then
MsgBox(0, '', '等待时间已到,退出')
ExitLoop
EndIf
Sleep(1000)
WEn
|