path:=A_ScriptDir
files:=[]
Loop, % path "\*.amr", 0,0
{
files[A_Index]:=A_LoopFileName
}
for i in files {
function("new",files[i])
}
Loop, % path "\*.amr", 0,0
{
if (!function("check",A_LoopFileName)) {
FileDelete, % A_LoopFileFullPath
}
}
return
F5::Reload
function(act,value=0,value2=0) {
static list:=[], max:=5
if (act="new") {
num :=RegExReplace(value, ".*@(.*)_.*","$1")
date:=RegExReplace(value, ".*@.*_(.*)","$1")
if (!list[num]["total"])
list[num]:=[],list[num]["total"]:=1, list[num][1]:=date
else if(list[num]["total"]=max)
function("add",num,date)
else list[num]["total"]+=1,i:=list[num]["total"],list[num][i]:=date
} else if(act="add") {
num:=value,date:=value2
for i,value in list[value] {
if(i="total")
Continue
if (IsLatest(date,value)) {
list[num][i]:=date
function("add",num,value)
return 1
}
} return 0
} else if(act="check") {
num :=RegExReplace(value, ".*@(.*)_.*","$1")
date:=RegExReplace(value, ".*@.*_(.*)","$1")
for i,value in list[num] {
if(list[num][i]=date)
return 1
} return 0
}
}
IsLatest(_1th,_2nd) {
_1th:=SplitDate(_1th)
_2nd:=SplitDate(_2nd)
if(_1th["year"]<_2nd["year"])
return 0
else if(_1th["year"]>_2nd["year"])
return 1
if(_1th["month"]<_2nd["month"])
return 0
else if(_1th["month"]>_2nd["month"])
return 2
if(_1th["day"]<_2nd["day"])
return 0
else if(_1th["day"]>_2nd["day"])
return 2
if(_1th["hour"]<_2nd["hour"])
return 0
else if(_1th["hour"]>_2nd["hour"])
return 2
if(_1th["min"]<_2nd["min"])
return 0
else if(_1th["min"]>_2nd["min"])
return 2
if(_1th["sec"]<_2nd["sec"])
return 0
return 6
}
SplitDate(date) {
var:="",out:=[]
loop,parse,date
{
if(!StrLen(var)&&!A_LoopField)
Continue
var.=A_LoopField
if(A_Index=4)
out["year"]:=var,var:=""
else if(A_Index=6)
out["month"]:=var,var:=""
else if(A_Index=8)
out["day"]:=var,var:=""
else if(A_Index=10)
out["hour"]:=var,var:=""
else if(A_Index=12)
out["min"]:=var,var:=""
else if(A_Index=14)
out["sec"]:=var,var:=""
} return out
;msgbox % date "`n" out["year"] "-" out["month"] "-" out["day"] "`n" out["hour"] ":" out["min"] ":" out["sec"]
}