本帖最后由 lion.lee 于 2011-12-21 14:40 编辑
我准备用这个代码测试一下能不用稳定运行。#include <file.au3>
#include <date.au3>
_filegetTime("F:\soft")
Func _filegetTime($path)
RunWait(@ComSpec & " /c " & "dir " & $path & " /tc >" & @ScriptDir & "\dirresult.txt", "", @SW_HIDE)
;将dir /od 修改为 dir /tc
$str = FileRead("dirresult.txt")
$str = StringReplace($str, " ", "")
FileDelete("dirresult.txt")
FileWrite("filetime.txt", $str)
Dim $array, $string, $timestr, $filename
_FileReadToArray("filetime.txt", $array)
FileDelete("filetime.txt")
For $i = 1 To $array[0]
If StringInStr($array[$i], "<DIR>") And Not StringInStr($array[$i], ".") Then
$string = StringSplit($array[$i], "<DIR>", 1)
$timestr = $string[1]
$filename = $string[2]
$timevalve = _DateToDayValue(StringLeft($timestr, 4), StringMid($timestr, 6, 2), StringMid($timestr, 9, 2))
$now = _DateToDayValue(@YEAR, @MON, @MDAY)
$tonow = $now - $timevalve
If $tonow > 5 Then
MsgBox(0, 0, $filename & "可以删除")
;DirRemove($path & "" & $filename, 1)
;路径忘记加上了,本次编辑补上
EndIf
EndIf
Next
EndFunc ;==>_filegetTime
|