Jump to content

Just delete the txt file?


Recommended Posts

Codes are deleting all files, but I just want to delete txt files.

$file = FileSelectFolder("Select Folder", @ScriptDir)
If $file = "" Or @error Then Exit
    $FileSearch = FileFindFirstFile($file & "*.txt")
    If $FileSearch <> 1 Then
        While 1
            $FileFind = FileFindNextFile($FileSearch)
            If @extended <> 0 Then ContinueLoop
            FileDelete($file & "\" & $FileFind)
            Sleep(500)
            FileClose($FileSearch)
        WEnd
    EndIf

 

Link to comment
Share on other sites

$file = FileSelectFolder("Select Folder", @ScriptDir)
If $file = "" Or @error Then Exit
$FileSearch = FileFindFirstFile($file & "\*.txt")
If $FileSearch <> -1 Then
    While 1
        $FileFind = FileFindNextFile($FileSearch)
        If @error Then ExitLoop
        FileDelete($file & "\" & $FileFind)
        Sleep(500)
        FileClose($FileSearch)
    WEnd
EndIf

 

Edited by Marc

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

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...