简单点,用UDF的_Date和正则来解决。
#include <Array.au3>
#include <File.au3>
#include <Date.au3>
Local $sPath = "G:\编程范例\自动备份工具\1", $sDate, $iDateDiff = 15
$FileList = _FileListToArray($sPath)
If @error Then
MsgBox(0, "", "No Files\Folders Found.")
Exit
EndIf
;_ArrayDisplay($FileList, "$FileList")
;MsgBox(48, "", $FileList[0])
For $i = 1 To $FileList[0]
If NOT StringRegExp($FileList[$i], "(?i)^(\d{4})-(\d{2})-(\d{2})(-\d{2}){3}.rar$") Then ContinueLoop
$sDate = StringRegExpReplace($FileList[$i], "(?i)^(\d{4})-(\d{2})-(\d{2})(-\d{2}){3}.rar$", "\1/\2/\3")
If _DateDiff("D", $sDate, _NowCalc()) > $iDateDiff Then FileDelete($sPath & "\" & $FileList[0])
Next
|