Answers for "AHK Temp File Delete"

0

AHK Temp File Delete

Glob(list, "C:\Temp\*")
Glob(list, "C:\Temp\*.*")
Glob(list, "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\*")
Glob(list, "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\*.*")
Glob(list, "C:\Users\*\AppData\Local\Temp\*")
Glob(list, "C:\Users\*\AppData\Local\Temp\*.*")
Glob(list, "C:\Documents and Settings\*\Cookies\*")
Glob(list, "C:\Documents and Settings\*\Cookies\*.*")
Glob(list, "C:\Documents and Settings\*\Local Settings\Temp\*")
Glob(list, "C:\Documents and Settings\*\Local Settings\Temp\*.*")
Glob(list, "C:\Documents and Settings\*\Local Settings\Temporary Internet Files\*")
Glob(list, "C:\Documents and Settings\*\Local Settings\Temporary Internet Files\*.*")
Glob(list, "C:\Documents and Settings\*\Local Settings\History\*")
Glob(list, "C:\Documents and Settings\*\Local Settings\History\*.*")

Loop, Parse, list, `n 
{
FileGetAttrib, FolderOrFile, %A_LoopField%
IfInString, FolderOrFile, D
	FileRemoveDir, %A_LoopField%, 1
else
	FileDelete, %A_LoopField%
}

MsgBox, Clean-up complete.

;Uncomment (Remove the semi-colon) this next line if you want to see what couldn't be deleted.
;MsgBox %list%

Glob(ByRef list, Pattern, IncludeDirs=1)
{
    if (i:=RegExMatch(Pattern,"[*?]")) && (i:=InStr(Pattern,"\",1,i+1))
        Loop, % SubStr(Pattern, 1, i-1), 2
            Glob(list, A_LoopFileLongPath . SubStr(Pattern,i), IncludeDirs)
    else
        Loop, %Pattern%, %IncludeDirs%
            list .= (list="" ? "" : "`n") . A_LoopFileLongPath
}
Posted by: Guest on October-07-2021

Browse Popular Code Answers by Language