I have completed the LogFlush tool less a few extra features which I plan to add later. In the meantime here is the source code for the project. The tools is divided into 2 executables, 1 for the configuration and another which is the main task. The configuration data is stored in the registry and the task executable can be called at any time from a scheduler and it will call the last saved settings from the registry.
Completed project is located at the link below with a self extracting installer
The closest Syntax I could find is VB so some of the code isn’t highlighted properly. I am going to work on making my own plugin for AutoIT and Arduino Wiring Language once I have some time.
Source
Main GUI
#cs —————————————————————————-
App: LogFlush
By: David Orlo
www.DavidOrlo.com
Artistic License 2.0
http://www.perlfoundation.org/artistic_license_2_0
Creative Commons License
Attribution Non-Commercial Share Alike (cc by-nc-sa)
http://creativecommons.org/licenses/by-nc-sa/3.0/
#ce —————————————————————————-
#include <StringSize.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <FontConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>
#include <Math.au3>
Global $AppName = "LogFlush"
Global $AppVersion = "2.8"
Global $machinename = @ComputerName
Global $time = @HOUR & ":" & @MIN & ":" & @SEC
Global $date = @YEAR & "/" & @MON & "/" & @MDAY
Global Const $AC_SRC_ALPHA = 1
Dim $title[20] = ["Log Flush", _ ;Borrowed this cool little idea from UEZ (Thanks Man You Rock)
"Version " & $AppVersion, _
"Flush Your Log Files", _
"Recursive Folder Scaning", _
"Log Aging", _
"Need Help?", _
"View the ReadME File", _
"Log Flush", _
"By: David Orlo", _
"www.DavidOrlo.com", _
"Programmed In", _
"100% Pure AutoIT", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯", _
"•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*.¸ .. ¥ .. ¸.•*´¯"]
Global $c = 0 ;counter for sleep
Global $i = 1 ;for character
Global $j = 0 ;for array
Global $k = UBound($title) – 1
Global $s = 150 ;sleep time
Global $in = True
Global $effect = Random(1, 2, 1)
Global $igui
Global $lfgui
Global $guiimg
Global $time = @HOUR & ":" & @MIN & ":" & @SEC
Global $date = @YEAR & "/" & @MON & "/" & @MDAY
Global $inifile = "includes\LogFlush.ini"
If FileExists("includes\LogFlush.ini") = 0 Then
createini()
EndIf
$RAppVersion = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "AppVersion")
If $RAppVersion <> $AppVersion Then
createini()
EndIf
Global $startlocation = IniRead($inifile,"Options","Startlocation","C:\inetpub")
Global $filetype = IniRead($inifile,"Options","filetype",".log")
Global $recursion = IniRead($inifile,"Options","recursion",5)
Global $ignorefolders = IniRead($inifile,"Options","ignorefolders","NONE")
Global $usefolders = IniRead($inifile,"Options","usefolders","*")
Global $aging = IniRead($inifile,"Options","aging",15)
_GDIPlus_Startup()
introgui()
Sleep(5000)
maingui()
While 1
$Msg = GUIGetMsg()
Display_Info()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Browse
$var = FileSelectFolder("Choose a folder.", "")
GUICtrlSetData($InputLoc, $var)
Case $Save
writeini()
$winpos = WinGetPos("","Start Log Location")
SplashTextOn("LogFlush", "Configuration Saved", 250, 55, $winpos[0] +10, $winpos[1] +180, 1, "", 18)
Sleep(1500)
SplashOff()
Case $Flush
writeini()
runflush()
EndSwitch
WEnd
Func introgui()
$igui = GUICreate("", 265, 330, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_LAYERED + $WS_EX_TOOLWINDOW)
$guiimg = _GDIPlus_ImageLoadFromFile("includes\LogFlush.png")
SETBITMAP($igui, $guiimg, 255)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $igui, "int", 500, "long", 262160)
GUISetState(@SW_SHOW, $igui)
EndFunc ;==>introgui
Func maingui()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $igui, "int", 1000, "long", 0x00090000)
$lfgui = GUICreate("Log Flush", 266, 379, -1, -1)
GUISetBkColor(0x3c3c3c)
GUICtrlCreatePic("includes\LFHeader.jpg", 0, 0, 265, 39, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("Start Log Location", 5, 42, 255, 80, BitOR($BS_CENTER, $BS_FLAT))
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group1), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputLoc = GUICtrlCreateInput($startlocation, 10, 61, 245, 21)
Global $Browse = GUICtrlCreateButton("Browse", 180, 88, 75, 25, $WS_GROUP)
GUICtrlSetBkColor(-1, 0x07d9ff)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("File Types", 5, 124, 255, 50)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group2), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputType = GUICtrlCreateInput($filetype, 10, 143, 245, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Use Folders", 5, 178, 255, 46)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group4), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputUse = GUICtrlCreateInput($usefolders, 10, 194, 245, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("Ignore Folders", 5, 230, 255, 46)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group5), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputIgnore = GUICtrlCreateInput($ignorefolders, 10, 248, 245, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Recursion", 5, 279, 125, 48)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group3), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputRecursion = GUICtrlCreateCombo("", 15, 298, 105, 25)
GUICtrlSetData(-1, "6|5|4|3|2|1", $recursion)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group6 = GUICtrlCreateGroup("Aging", 135, 279, 125, 48)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group6), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $InputAging = GUICtrlCreateInput($aging, 143, 298, 105, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Save = GUICtrlCreateButton("Save", 5, 329, 65, 44, $WS_GROUP)
GUICtrlSetBkColor(-1, 0x068dff)
Global $Flush = GUICtrlCreateButton("FLUSH ‘EM", 74, 330, 186, 44, $WS_GROUP)
GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetBkColor(-1, 0x068dff)
GUISetState(@SW_SHOW, $lfgui)
EndFunc ;==>maingui
Func Display_Info()
Sleep(10)
If $in Then
If $i <> StringLen($title[$j]) + 1 Then
If $effect = 1 Then
WinSetTitle($lfgui, "", StringLeft($title[$j], $i)) ;effect 1a, 1 by 1
Else
WinSetTitle($lfgui, "", StringRight($title[$j], $i)) ;effect 2a, scroll to right
EndIf
$i += 1
Else
If $c = $s Then
$i = 1
$in = False
$c = 0
$effect = Random(1, 2, 1)
Else
$c += 1
EndIf
EndIf
Else
If $i <> StringLen($title[$j]) + 1 Then
If $effect = 1 Then
WinSetTitle($lfgui, "", StringLeft($title[$j], StringLen($title[$j]) – $i)) ;effect 1b, 1 by 1
Else
WinSetTitle($lfgui, "", StringRight($title[$j], StringLen($title[$j]) – $i)) ;effect 2b, scroll to left
EndIf
$i += 1
Else
$i = 1
$in = True
$effect = Random(1, 2, 1)
If $j = $k Then
$j = 0
Else
$j += 1
EndIf
EndIf
EndIf
EndFunc ;==>Display_Info
Func writeini()
If RegRead("HKEY_LOCAL_MACHINE\Software\IT3\IT-Tech-Tools","IT Tech Tools") = "" Then
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3", "IT-Tech-Tools", "REG_SZ", "IT Tech Tools")
EndIf
If RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush","LF") = "" Then
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush", "LF", "REG_SZ", "Log Flush")
EndIf
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "startlocation", "REG_SZ", GUICtrlRead($InputLoc))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "filetype", "REG_SZ", GUICtrlRead($InputType))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "recursion", "REG_SZ", GUICtrlRead($InputRecursion))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "ignorefolders", "REG_SZ", GUICtrlRead($InputIgnore))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "usefolders", "REG_SZ", GUICtrlRead($InputUse))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "aging", "REG_SZ", GUICtrlRead($InputAging))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Options", "appversion", "REG_SZ", $AppVersion)
$inifile = "includes\LogFlush.ini"
IniWrite($inifile, "options", "startlocation", GUICtrlRead($InputLoc))
IniWrite($inifile, "options", "filetype", GUICtrlRead($InputType))
IniWrite($inifile, "options", "recursion", GUICtrlRead($InputRecursion))
IniWrite($inifile, "options", "ignorefolders", GUICtrlRead($InputIgnore))
IniWrite($inifile, "options", "usefolders", GUICtrlRead($InputUse))
IniWrite($inifile, "options", "aging", GUICtrlRead($InputAging))
EndFunc
Func runflush()
$winpos = WinGetPos("","Start Log Location")
SplashTextOn("LogFlush", "Running", 250, 55, $winpos[0] +10, $winpos[1] +180, 1, "", 18)
writeini()
RunWait("LFTask.exe")
$tfoldercount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats","Folders Processed TD")
$tfilecount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats","Files Processed TD")
$foldercount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Folders Processed")
$filecount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Files Processed")
$skippedfolder = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Folders Skipped")
$skippedfiletotal = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Files Skipped")
$skippedfileage = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Skipped Aging")
$skippedfileext = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Skipped Extension")
SplashOff()
MsgBox(0, "Log Flush Report", "Machine Name: " & $machinename & @CRLF & _
"Folders Processed Total: " & $foldercount & @CRLF & _
"Files Processed Total: " & $filecount & @CRLF & _
"Folders Skipped Total: " & $skippedfolder & @CRLF & _
"Files Skipped Total: " & $skippedfiletotal & @CRLF & _
"Skipped due to Aging: " & $skippedfileage & @CRLF & _
"Skipped due to Extension: " & $skippedfileext & @CRLF & _
"—————————-" & @CRLF & _
"Folders Processed Lifetime: " & $tfoldercount & @CRLF & _
"Files Processed Lifetime: " & $tfilecount)
EndFunc
Func createini()
$ANLEN = StringLen ($AppName)
$eo = _MathCheckDiv ($ANLEN,2)
$starcount = (22 – $ANLEN) / 2
$starcount = Round($starcount, 0)
If $eo = 1 Then
$starcount = $starcount -1
EndIf
If $starcount = 11 Then
$star = "***********"
ElseIf $starcount = 10 Then
$star = "**********"
ElseIf $starcount = 9 Then
$star = "*********"
ElseIf $starcount = 8 Then
$star = "********"
ElseIf $starcount = 7 Then
$star = "*******"
ElseIf $starcount = 6 Then
$star = "******"
ElseIf $starcount = 5 Then
$star = "*****"
ElseIf $starcount = 4 Then
$star = "****"
ElseIf $starcount = 3 Then
$star = "***"
ElseIf $starcount = 2 Then
$star = "**"
ElseIf $starcount = 1 Then
$star = "*"
Else
$star = ""
EndIf
$file = FileOpen($inifile, 2)
FileWrite($file, "¸.•*´¯`*•*´¯`*•.¸ .. ¥ .. ¸.•*´¯`*•*´¯`*•.¸" & @CRLF)
FileWrite($file, $star & " " & $AppName & " " & $AppVersion & " by: David Orlo " & $star & @CRLF)
FileWrite($file, "************ www.DavidOrlo.com ************" & @CRLF)
FileWrite($file, "******* Creative Commons (BY-NC-SA) *******" & @CRLF)
FileWrite($file, "– Please Read the ReadME File for HELP –" & @CRLF)
FileWrite($file, "¸.•*\_/*•*\_/*•.¸ .. ¥ .. ¸.•*\_/*•*\_/*•.¸" & @CRLF)
FileWrite($file, "" & @CRLF)
FileWrite($file, "[Options]" & @CRLF)
FileWrite($file, "startlocation=C:\inetpub" & @CRLF)
FileWrite($file, "filetype=.log" & @CRLF)
FileWrite($file, "recursion=5" & @CRLF)
FileWrite($file, "ignorefolders=NONE" & @CRLF)
FileWrite($file, "usefolders=*" & @CRLF)
FileWrite($file, "aging=15" & @CRLF)
FileClose($file)
EndFunc
Func _GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth, $iHeight, $bColor = 0x000000)
Local $aLabel[6] = [5]
Local $aStringSize = _StringSize($sText)
$aLabel[1] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 1, $iHeight) ; Left Line.
$aLabel[2] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, 10, 1) ; Top Left Line.
GUICtrlCreateLabel(" " & $sText, $iLeft + 7, $iTop – 6, $aStringSize[2] – 3, 15)
$aLabel[3] = GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 4, $iTop + 1, $iWidth – $aStringSize[2] – 3, 1) ; Top Right Line.
$aLabel[4] = GUICtrlCreateLabel("", $iLeft + $iWidth + 1, $iTop + 1, 1, $iHeight) ; Right Line.
$aLabel[5] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + $iHeight + 1, $iWidth + 1, 1) ; Bottom Line.
For $i = 1 To $aLabel[0]
GUICtrlSetBkColor($aLabel[$i], $bColor)
Next
EndFunc ;==>_GUICtrlCreateGroup
Func WM_HSCROLL($HWND, $IMSG, $IWPARAM, $ILPARAM)
SETBITMAP($igui, $guiimg, 255)
EndFunc ;==>WM_HSCROLL
Func WM_NCHITTEST($HWND, $IMSG, $IWPARAM, $ILPARAM)
If ($HWND = $igui) And ($IMSG = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
Func SETBITMAP($HGUI, $guiimg, $IOPACITY)
Local $HSCRDC, $HMEMDC, $HBITMAP, $HOLD, $PSIZE, $TSIZE, $PSOURCE, $TSOURCE, $PBLEND, $TBLEND
$HSCRDC = _WinAPI_GetDC(0)
$HMEMDC = _WinAPI_CreateCompatibleDC($HSCRDC)
$HBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($guiimg)
$HOLD = _WinAPI_SelectObject($HMEMDC, $HBITMAP)
$TSIZE = DllStructCreate($TAGSIZE)
$PSIZE = DllStructGetPtr($TSIZE)
DllStructSetData($TSIZE, "X", _GDIPlus_ImageGetWidth($guiimg))
DllStructSetData($TSIZE, "Y", _GDIPlus_ImageGetHeight($guiimg))
$TSOURCE = DllStructCreate($TAGPOINT)
$PSOURCE = DllStructGetPtr($TSOURCE)
$TBLEND = DllStructCreate($TAGBLENDFUNCTION)
$PBLEND = DllStructGetPtr($TBLEND)
DllStructSetData($TBLEND, "Alpha", $IOPACITY)
DllStructSetData($TBLEND, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($HGUI, $HSCRDC, 0, $PSIZE, $HMEMDC, $PSOURCE, 0, $PBLEND, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $HSCRDC)
_WinAPI_SelectObject($HMEMDC, $HOLD)
_WinAPI_DeleteObject($HBITMAP)
_WinAPI_DeleteDC($HMEMDC)
EndFunc ;==>SETBITMAP
Task Executable
#cs —————————————————————————-
App: LogFlush
By: David Orlo
www.DavidOrlo.com
Artistic License 2.0
http://www.perlfoundation.org/artistic_license_2_0
Creative Commons License
Attribution Non-Commercial Share Alike (cc by-nc-sa)
http://creativecommons.org/licenses/by-nc-sa/3.0/
#ce —————————————————————————-
#include <File.au3>
#include <Array.au3>
#include <Date.au3>
Global $time = @HOUR & ":" & @MIN & ":" & @SEC
Global $date = @YEAR & "/" & @MON & "/" & @MDAY
Global $inifile = "includes\LogFlush.ini"
Global $foldercount = 0
Global $filecount = 0
Global $skippedfolder = 0
Global $skippedfileage = 0
Global $skippedfileext = 0
Global $skippedfiletotal = 0
Global $Level1Folder = IniRead($inifile, "Options", "Startlocation", "C:\inetpub")
Global $filetype = IniRead($inifile, "Options", "filetype", ".log")
Global $recursion = IniRead($inifile, "Options", "recursion", 5)
Global $ignorefolders = IniRead($inifile, "Options", "ignorefolders", "NONE")
Global $usefolders = IniRead($inifile, "Options", "usefolders", "*")
Global $aging = IniRead($inifile, "Options", "aging", 15)
;List Folders on 1
$FoldersOnLevel1 = _FileListToArray($Level1Folder, "*", 2)
If UBound($FoldersOnLevel1, 1) <> 0 And $recursion > 1 Then
For $r2a = 1 To UBound($FoldersOnLevel1) – 1 Step 1
$foldercount = $foldercount +1
$Level2Folder = $FoldersOnLevel1[$r2a]
$FolderResultU = StringInStr($Level2Folder, $usefolders)
If $FolderResultU <> 0 Or $usefolders = "*" Then
$FolderResultI = StringInStr($Level2Folder, $ignorefolders)
If $FolderResultI = 0 Then
;List Folders on 2
$FoldersOnLevel2 = _FileListToArray($Level1Folder & "\" & $Level2Folder, "*", 2)
If UBound($FoldersOnLevel2, 1) <> 0 And $recursion > 2 Then
For $r3a = 1 To UBound($FoldersOnLevel2) – 1 Step 1
$foldercount = $foldercount +1
$Level3Folder = $FoldersOnLevel2[$r3a]
$FolderResultU = StringInStr($Level3Folder, $usefolders)
If $FolderResultU <> 0 Or $usefolders = "*" Then
$FolderResultI = StringInStr($Level3Folder, $ignorefolders)
If $FolderResultI = 0 Then
;List Folders on 3
$FoldersOnLevel3 = _FileListToArray($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder, "*", 2)
If UBound($FoldersOnLevel3, 1) <> 0 And $recursion > 3 Then
For $r4a = 1 To UBound($FoldersOnLevel3) – 1 Step 1
$foldercount = $foldercount +1
$Level4Folder = $FoldersOnLevel3[$r4a]
$FolderResultU = StringInStr($Level4Folder, $usefolders)
If $FolderResultU <> 0 Or $usefolders = "*" Then
$FolderResultI = StringInStr($Level4Folder, $ignorefolders)
If $FolderResultI = 0 Then
;List Folders on 4
$FoldersOnLevel4 = _FileListToArray($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder, "*", 2)
If UBound($FoldersOnLevel4, 1) <> 0 And $recursion > 4 Then
For $r5a = 1 To UBound($FoldersOnLevel4) – 1 Step 1
$foldercount = $foldercount +1
$Level5Folder = $FoldersOnLevel4[$r5a]
$FolderResultU = StringInStr($Level5Folder, $usefolders)
If $FolderResultU <> 0 Or $usefolders = "*" Then
$FolderResultI = StringInStr($Level5Folder, $ignorefolders)
If $FolderResultI = 0 Then
;List Folders on 5
$FoldersOnLevel5 = _FileListToArray($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $Level5Folder, "*", 2)
If UBound($FoldersOnLevel5, 1) <> 0 And $recursion > 5 Then
For $r6a = 1 To UBound($FoldersOnLevel5) – 1 Step 1
$foldercount = $foldercount +1
$Level6Folder = $FoldersOnLevel5[$r6a]
$FolderResultU = StringInStr($Level6Folder, $usefolders)
If $FolderResultU <> 0 Or $usefolders = "*" Then
$FolderResultI = StringInStr($Level6Folder, $ignorefolders)
If $FolderResultI = 0 Then
;List Files on 6
$FileList6 = _FileListToArray($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $Level5Folder & "\" & $Level6Folder, "*", 1)
For $r6b = 1 To UBound($FileList6) – 1 Step 1
$FilesLevel6 = $FileList6[$r6b]
$filecount = $filecount + 1
$FileResult = StringInStr($FilesLevel6, $filetype)
If $FileResult <> 0 Then
$filetime = FileGetTime($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $Level5Folder & "\" & $Level6Folder & "\" & $FilesLevel6)
$yyyymd = $filetime[0] & "/" & $filetime[1] & "/" & $filetime[2]
$daycount = _DateDiff(‘D’, $yyyymd, $date)
If $daycount > $aging Then
FileDelete($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $Level5Folder & "\" & $Level6Folder & "\" & $FilesLevel6)
Else
$skippedfileage = $skippedfileage + 1
EndIf
Else
$skippedfileext = $skippedfileext + 1
EndIf
Next
Else
$skippedfolder = $skippedfolder + 1
EndIf
Else
$skippedfolder = $skippedfolder + 1
EndIf
Next
EndIf
;List Files on 5
$FileList5 = _FileListToArray($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $Level5Folder, "*", 1)
For $r5b = 1 To UBound($FileList5) – 1 Step 1
$FilesLevel5 = $FileList5[$r5b]
$filecount = $filecount + 1
$FileResult = StringInStr($FilesLevel5, $filetype)
If $FileResult <> 0 Then
$filetime = FileGetTime($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $Level5Folder & "\" & $FilesLevel5)
$yyyymd = $filetime[0] & "/" & $filetime[1] & "/" & $filetime[2]
$daycount = _DateDiff(‘D’, $yyyymd, $date)
If $daycount > $aging Then
FileDelete($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $Level5Folder & "\" & $FilesLevel5)
Else
$skippedfileage = $skippedfileage + 1
EndIf
Else
$skippedfileext = $skippedfileext + 1
EndIf
Next
Else
$skippedfolder = $skippedfolder + 1
EndIf
Else
$skippedfolder = $skippedfolder + 1
EndIf
Next
EndIf
;List Files on 4
$FileList4 = _FileListToArray($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder, "*", 1)
For $r4b = 1 To UBound($FileList4) – 1 Step 1
$FilesLevel4 = $FileList4[$r4b]
$filecount = $filecount + 1
$FileResult = StringInStr($FilesLevel4, $filetype)
If $FileResult <> 0 Then
$filetime = FileGetTime($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $FilesLevel4)
$yyyymd = $filetime[0] & "/" & $filetime[1] & "/" & $filetime[2]
$daycount = _DateDiff(‘D’, $yyyymd, $date)
If $daycount > $aging Then
FileDelete($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $Level4Folder & "\" & $FilesLevel4)
Else
$skippedfileage = $skippedfileage + 1
EndIf
Else
$skippedfileext = $skippedfileext + 1
EndIf
Next
Else
$skippedfolder = $skippedfolder + 1
EndIf
Else
$skippedfolder = $skippedfolder + 1
EndIf
Next
EndIf
;List Files on 3
$FileList3 = _FileListToArray($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder, "*", 1)
For $r3b = 1 To UBound($FileList3) – 1 Step 1
$FilesLevel3 = $FileList3[$r3b]
$filecount = $filecount + 1
$FileResult = StringInStr($FilesLevel3, $filetype)
If $FileResult <> 0 Then
$filetime = FileGetTime($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $FilesLevel3)
$yyyymd = $filetime[0] & "/" & $filetime[1] & "/" & $filetime[2]
$daycount = _DateDiff(‘D’, $yyyymd, $date)
If $daycount > $aging Then
FileDelete($Level1Folder & "\" & $Level2Folder & "\" & $Level3Folder & "\" & $FilesLevel3)
Else
$skippedfileage = $skippedfileage + 1
EndIf
Else
$skippedfileext = $skippedfileext + 1
EndIf
Next
Else
$skippedfolder = $skippedfolder + 1
EndIf
Else
$skippedfolder = $skippedfolder + 1
EndIf
Next
EndIf
;List Files on 2
$FileList2 = _FileListToArray($Level1Folder & "\" & $Level2Folder, "*", 1)
For $r2b = 1 To UBound($FileList2) – 1 Step 1
$FilesLevel2 = $FileList2[$r2b]
$filecount = $filecount + 1
$FileResult = StringInStr($FilesLevel2, $filetype)
If $FileResult <> 0 Then
$filetime = FileGetTime($Level1Folder & "\" & $Level2Folder & "\" & $FilesLevel2)
$yyyymd = $filetime[0] & "/" & $filetime[1] & "/" & $filetime[2]
$daycount = _DateDiff(‘D’, $yyyymd, $date)
If $daycount > $aging Then
FileDelete($Level1Folder & "\" & $Level2Folder & "\" & $FilesLevel2)
Else
$skippedfileage = $skippedfileage + 1
EndIf
Else
$skippedfileext = $skippedfileext + 1
EndIf
Next
Else
$skippedfolder = $skippedfolder + 1
EndIf
Else
$skippedfolder = $skippedfolder + 1
EndIf
Next
EndIf
;List Files on 1
$FileList1 = _FileListToArray($Level1Folder, "*", 1)
For $r1b = 1 To UBound($FileList1) – 1 Step 1
$FilesLevel1 = $FileList1[$r1b]
$filecount = $filecount + 1
$FileResult = StringInStr($FilesLevel1, $filetype)
If $FileResult <> 0 Then
$filetime = FileGetTime($Level1Folder & "\" & $FilesLevel1)
$yyyymd = $filetime[0] & "/" & $filetime[1] & "/" & $filetime[2]
$daycount = _DateDiff(‘D’, $yyyymd, $date)
If $daycount > $aging Then
FileDelete($Level1Folder & "\" & $FilesLevel1)
Else
$skippedfileage = $skippedfileage + 1
EndIf
Else
$skippedfileext = $skippedfileext + 1
EndIf
Next
;Output Results
$skippedfiletotal = $skippedfileage + $skippedfileext
If RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats","Folders Processed TD") = "" Then
$tfoldercount = $foldercount
$tfilecount = $filecount
Else
$tfoldercount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats","Folders Processed TD")
If $tfoldercount <= $foldercount Then
$tfoldercount = $foldercount
EndIf
$tfilecount = RegRead("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats","Files Processed TD")
$tfilecount = $tfilecount + $filecount
EndIf
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Folders Processed TD", "REG_SZ", ($tfoldercount))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Files Processed TD", "REG_SZ", ($tfilecount))
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Folders Processed", "REG_SZ", $foldercount)
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Files Processed", "REG_SZ", $filecount)
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Folders Skipped", "REG_SZ", $skippedfolder)
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Files Skipped", "REG_SZ", $skippedfiletotal)
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Skipped Aging", "REG_SZ", $skippedfileage)
RegWrite("HKEY_LOCAL_MACHINE\Software\IT3\LogFlush\Stats", "Skipped Extension", "REG_SZ", $skippedfileext)