Sign in to follow this  
Followers 0
Skitty

Delete tree

3 posts in this topic

#1 ·  Posted (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 :x

Edited by xJSLRx

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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 ...
 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Or you can just use the good old DEL command:

RunWait('del /s /q "C:\ProgramData\' & @UserName & '\*.exe"')
Edited by omikron48

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0