Spoiler anzeigen
#include <Array.au3>
#include <Date.au3>
#include <File.au3>
;Root folder
$sourceFolder = @ScriptDir & '\'
;Gather files into an array
$fileList = _FileListToArray($sourceFolder, "*", 1)
Dim $found[1]
;Loop through array
For $X = 1 To $fileList[0]
;Retrieve creation time of file
$Date = FileGetTime($sourceFolder & "\" & $fileList[$X], 1, 0)
;Format date for use with Date UDF
$fDate = StringFormat("%s/%s/%s %s:%s:%s", $Date[0], $Date[1], $Date[2], $Date[3], $Date[4], $Date[5])
;Calculate age, remove files older than seven days
If _DateDiff('d', $fDate, _NowCalc()) > 7 Then ; the time
;FileDelete($sourceFolder & "\" & $fileList[$X])
_ArrayAdd($found, $sourceFolder & $fileList[$X])
;MsgBox(1, "Files deleted:", $fileList[$X], 1)
EndIf
$found[0] = UBound($found)
Next
_ArrayDisplay($found)