Jump to content

Similar to my earlier thread ->


BALA
 Share

Recommended Posts

I modified a code I found on the Internet to delete Temp files. For some reason it won't change the directory in which it searches to the one the user specifies in the GUI.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-LETED", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$input = GUICtrlCreateInput("C:\", 10, 70, 180, 20)

$begin = GUICtrlCreateButton("BA-LETE", 80, 20, 120)
GUICtrlSetOnEvent($begin, "Begin")

Dim $FolderName = GUICtrlRead($input)
Dim $FileCount = 0
Dim $FileCountDel = 0

Func CLOSEClicked()
    Exit
EndFunc

Func Begin()    
    ScanFolder($FolderName)
    
    MsgBox(0,"Done","Folder Scan Complete.  Scanned " & $FileCount & "Files.  BA-LETED " & $FileCountDel & " Files")

    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt","")
    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt","You scanned " & $FileCount & " Files")
    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt","You BA-LETED " & $FileCountDel & " Files!")
EndFunc

Func ScanFolder($SourceFolder)
    Local $Search
    Local $File
    Local $FileAttributes
    Local $FullFilePath

    $Search = FileFindFirstFile($SourceFolder & "\*.*")
 
    While 1
        If $Search = -1 Then
            ExitLoop
        EndIf

        $File = FileFindNextFile($Search)
        If @error Then ExitLoop

        $FullFilePath = $SourceFolder & "\" & $File
        $FileAttributes = FileGetAttrib($FullFilePath)

        If StringInStr($FileAttributes,"D") Then
            ScanFolder($FullFilePath)
        Else
            ToolTip($FullFilePath,0,0)
            $FileCount += 1
        EndIf
        If StringInStr($FileAttributes,"T") Then
            FileDelete($FullFilePath)
            LogFile($FullFilePath)
        EndIf
 
    WEnd
 
    FileClose($Search)
EndFunc
 
Func LogFile($FileName)
    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt",$FileName)
    $FileCountDel += 1
EndFunc

While 1
    sleep(10)
WEnd
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

  • Developers

You are doing the GUIread() at the wrong spot... needs to be done when the button is click so inside Begin()..

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...