Break ON
Dim $aRecent[], $a1Year[], $a2Years[], $a3Years[], $a4Years[], $aOld[]
$dir = "C:\temp"
$log = "C:\temp\Unused Files [Temp].log"
$lArq = "N"
$Files = DirList($dir+"\*.*",2+4)
If EXIST ($log)
DEL $log
EndIf
If Open( 3 , $log , 5 ) <> 0
Beep
? "Error Code : [" + @ERROR + "]"
EndIf
For Each $File in $Files
SELECT
CASE DateCalc(@date,substr(getfiletime($File),1,10)) <= 365
REDIM PRESERVE $aRecent[1+UBOUND($aRecent)]
$aRecent[UBOUND($aRecent)] = $File
CASE DateCalc(@date,substr(getfiletime($File),1,10)) >= 366 And DateCalc(@date,substr(getfiletime($File),1,10)) <= 730
REDIM PRESERVE $a1Year[1+UBOUND($a1Year)]
$a1Year[UBOUND($a1Year)] = $File
CASE DateCalc(@date,substr(getfiletime($File),1,10)) >= 731 And DateCalc(@date,substr(getfiletime($File),1,10)) <= 1095
REDIM PRESERVE $a2Years[1+UBOUND($a2Years)]
$a2Years[UBOUND($a2Years)] = $File
CASE DateCalc(@date,substr(getfiletime($File),1,10)) >= 1096 And DateCalc(@date,substr(getfiletime($File),1,10)) <= 1460
REDIM PRESERVE $a3Years[1+UBOUND($a3Years)]
$a3Years[UBOUND($a3Years)] = $File
CASE DateCalc(@date,substr(getfiletime($File),1,10)) >= 1461 And DateCalc(@date,substr(getfiletime($File),1,10)) <= 1825
REDIM PRESERVE $a4Years[1+UBOUND($a4Years)]
$a4Years[UBOUND($a4Years)] = $File
CASE DateCalc(@date,substr(getfiletime($File),1,10)) >= 1826
REDIM PRESERVE $aOld[1+UBOUND($aOld)]
$aOld[UBOUND($aOld)] = $File
ENDSELECT
Next
$x = WriteLine( 3 , "Files : " + (UBOUND($Files)+1) + @CRLF )
$x = WriteLine( 3 , " "+ @CRLF )
$x = WriteLine( 3 , "Recent : " + (UBOUND($aRecent)+1) + @CRLF )
MyFunc( $aRecent, "Recent" )
$x = WriteLine( 3 , "1 Year : " + (UBOUND($a1Year)+1) + @CRLF )
MyFunc( $a1Year, "1 Ano" )
$x = WriteLine( 3 , "2 Years : " + (UBOUND($a2Years)+1) + @CRLF )
MyFunc( $a2Years, "2 Years" )
$x = WriteLine( 3 , "3 Years : " + (UBOUND($a3Years)+1) + @CRLF )
MyFunc( $a3Years, "3 Years" )
$x = WriteLine( 3 , "4 Years : " + (UBOUND($a4Years)+1) + @CRLF )
MyFunc( $a4Years, "4 Years" )
$x = WriteLine( 3 , "Above 5 Years : " + (UBOUND($aOld)+1) + @CRLF )
MyFunc( $aOld, "Above 5 Years" )
$x = Close(3)
Function MyFunc( $pArray, $cTime )
$nSize = 0
For Each $Element In $pArray
If $lArq == "S"
$x = WriteLine( 3 , " - " + $Element + @CRLF )
EndIf
$nSize = $nSize + GetFileSize($Element)
Next
$x = WriteLine( 3 , " * Size ["+$cTime+"] : " + FormatNumber((1.0 * $nSize), 2) + " bytes" + @CRLF )
$x = WriteLine( 3 , "" + @CRLF )
$x = WriteLine( 3 , "" + @CRLF )
EndFunction