Jump to content
Sign in to follow this  
DoctorX

DirRemove with partial folder name

Recommended Posts

DoctorX

Is there a way to use wildcards with DirRemove? What I want to do is remove a folder which does not always have the same name, but it begins with the same two letters.

Essentially I am looking for the equivalent of this:

FileDelete (@TempDir & "\f4*.*")

Except I need to do the same for all folders that begin with "f4".

Any ideas?


-DRX

Share this post


Link to post
Share on other sites
Valuater

this will do the trick

#Include <File.au3>
#Include <Array.au3>

Dim $location = @TempDir

$FileList=_FileListToArray($location, "f4*", 2)
If (Not IsArray($FileList)) Or (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")

; clear these comments "#cs & #ce" when you are sure... very sure
; this will DELETE ALL FILES INSIDE f4* FOLDERS
#cs
If $FileList[0] >=1 Then
    For $x = 1 to $FileList[0]
        DirRemove($location & "\" & $FileList[$x], 1)
    Next
EndIf
#ce

8)


NEWHeader1.png

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  

×