Skitty Posted January 2, 2011 Share Posted January 2, 2011 (edited) I have this script that deletes files by extension and size but I wan't It to reach all the way through and into sub directories as well, is there a function Im missing here? _Clean() Func _Clean() FileDelete("C:\ProgramData\" & @UserName & "\*.exe") FileDelete("C:\ProgramData\" & @UserName & "\*.au3") FileDelete("C:\ProgramData\" & @UserName & "\*.bat") FileDelete("C:\ProgramData\" & @UserName & "\*.com") FileDelete("C:\ProgramData\" & @UserName & "\*.ini") FileChangeDir("C:\ProgramData\" & @Username) $search = FileFindFirstFile("*.*") While 1 $file = FileFindNextFile($search) $size = FileGetSize($file) / 1048576 If @error Then ExitLoop If $size < 1 Then ContinueLoop Else FileDelete($file) EndIf WEnd FileClose($search) EndFunc Edit: deleting the sub directories would be nice too Edited January 2, 2011 by xJSLRx Link to comment Share on other sites More sharing options...
MvGulik Posted January 2, 2011 Share Posted January 2, 2011 (edited) I wan't It to reach all the way through and into sub directories as well, is there a function Im missing here?In a way you are. You need to use FileFindNextFile() for this to.1) FileFindNextFile: @extended set to 1 if filename is a directory.2) Look in Melba's signature. (RecFileListToArray)3) search forum for some additional topics on folder recursion. Edited January 2, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
omikron48 Posted January 2, 2011 Share Posted January 2, 2011 (edited) Or you can just use the good old DEL command: RunWait('del /s /q "C:\ProgramData\' & @UserName & '\*.exe"') Edited January 2, 2011 by omikron48 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now