Jump to content
Sign in to follow this  
hot202

Delete all file types in a folder.

Recommended Posts

hot202

Ok guys i wanted to know how i can delete all .doc out of a folder. I use FileSelectFolder and IniWrite to save the location of the folder. so i will use iniread then i need to know what to add to delete all same file types.

Share this post


Link to post
Share on other sites
Andreik

Check FileDelete() function. Wildcards are supported. >_


When the words fail... music speaks

Share this post


Link to post
Share on other sites
hot202

thanks heaps also how would i be able to add checkboxes each 1 deletes a diff filetype and if its checked i click delete button and it deletes the files but dosnt deleate the ones that aint ticked? dose that make sence?

Share this post


Link to post
Share on other sites
Andreik

Hope I understand corect:

#include <GuiListView.au3>
#include <File.au3>

$DIR = FileSelectFolder("Select","")
$EXT = InputBox("Extension","Please type files extension.","*.txt")
GetDelFiles($DIR,$EXT)

Func GetDelFiles($DIR,$EXT)
    Local $FILE = _FileListToArray($DIR,$EXT,1)
    Local $GUI = GUICreate("Delete Files",300,300,-1,-1,0x16C80000,0x00000181)
    Local $LIST = GUICtrlCreateListView("File",5,5,290,250,0x00200000,BitOR(0x00000004,0x00000200))
    _GUICtrlListView_SetColumnWidth($LIST,0,280)
    For $INDEX = 1 To $FILE[0]
        $ITEM = GUICtrlCreateListViewItem($FILE[$INDEX],$LIST)
    Next
    $DEL = GUICtrlCreateButton("Delete",100,270,100,20)
    GUISetState(@SW_SHOW,$GUI)
    While True
        $MSG = GUIGetMsg()
        If $MSG = -3 Then
            Exit
        ElseIf $MSG = $DEL Then
            For $INDEX = 1 To $FILE[0]
                If _GUICtrlListView_GetItemChecked($LIST,$INDEX-1) Then
                    FileDelete($DIR & "\" & $FILE[$INDEX])
                EndIf
            Next
            GUIDelete($GUI)
            MsgBox(0x40,"Info","Selected file(s) was deleted.")
            ExitLoop
        EndIf
        Sleep(15)
    WEnd
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites
hot202

thanks but what i mean is i will have check boxes 4 the file types that i wanted deleted.

if a checkbox it ticked when i click the delete button it will only delete the file type i set that checkbox to be

soit wont delete the other file types unless the checkboxes r ticked.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.