Jump to content

Recommended Posts

Please check Melba's

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-11-10 - Version 1.6.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

I don't think the standard FLTA allows multiple filters. You'd likely want to use one of the many recursive versions of FLTA that are floating around, as most of them allow multiple search filters. I'm fond of some of the team efforts that came out of thread #96952. The example below, from that thread, is at 64 lines one of the smallest and fastest around:

#include <Array.au3>
#include <File.au3>

$timer = TimerInit()
$aArray = _FileListToArrayPlus(@WindowsDir, "*.dll;*.exe", 1, "", "", 1, False)
$timer = Round(TimerDiff($timer) / 1000, 2) & ' sec'
_ArrayDisplay($aArray, $timer)

; #FUNCTION# =====================================================================================================================
; _FileListToArrayPlus($sPath, $sInclude = "*", $iFlag = 0, $sExcludeFolder = "", $sExclude = "", $iPathType = 0, $bRecursive = False)
; Name...........:  _FileListToArrayPlus
; Parameters ....:  $sPath: Folder to search
;     $sInclude: String to match on (wildcards allowed, multiples delimited by ;)
;     $iFlag: Returned data type. 0 = Files and folders (default), 1 = Files only, 2 = Folders only
;     $sExcludeFolder: List of folders to exclude from search (wildcards allowed, multiples delimited by ;)
;     $sExclude: List of filenames to exclude from search (wildcards allowed, multiples delimited by ;)
;     $iPathType: Returned data format. 0 = Filename only (default), 1 = Path relative to $sPath, 2 = Full path/filename
;     $bRecursive: 0 = Search $sPath folder only (default), 1 = Search $sPath and all subfolders
; Author ........:  Forum thread #96952
;===================================================================================================================================
;===================================================================================================================================
Func _FileListToArrayPlus($sPath, $sInclude = "", $iFlag = 0, $sExcludeFolder = "", $sExclude = "", $iPathType = 0, $bRecursive = False)
    Local $sRet = "", $sReturnFormat = ""
    $sPath = StringRegExpReplace($sPath, "[/]+z", "") & "" ; ensure single trailing slash
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    ; Edit include files list
    If $sInclude = "*" Then $sInclude = ""
    If $sInclude Then
        If StringRegExp($sInclude, "[/:><|]|(?s)As*z") Then Return SetError(2, 2, "") ; invalid characters test
        $sInclude = StringRegExpReplace(StringRegExpReplace($sInclude, "(s*;s*)+", ";"), "A;|;z", "") ; Strip unwanted whitespace
        $sInclude = StringRegExpReplace($sInclude, "[][$.+^{}()]", "$0"); Ignore special characters
        $sInclude = StringReplace(StringReplace(StringReplace($sInclude, "?", "."), "*", ".*?"), ";", "$|") ; Convert ? to ., * to .*?, and ; to |
        $sInclude = "(?i)A(" & $sInclude & "$)"; case-insensitive, match from first char, terminate strings
    EndIf
    ; Edit exclude folders list
    If $sExcludeFolder Then
        $sExcludeFolder = StringRegExpReplace(StringRegExpReplace($sExcludeFolder, "(s*;s*)+", ";"), "A;|;z", "") ; Strip unwanted whitespace
        $sExcludeFolder = StringRegExpReplace($sExcludeFolder, "[][$.+^{}()]", "$0"); Ignore special characters
        $sExcludeFolder = StringReplace(StringReplace(StringReplace($sExcludeFolder, "?", "."), "*", ".*?"), ";", "$|") ; Convert ?=.  *=.*?  ;=|
        $sExcludeFolder = "(?i)A(?!" & $sExcludeFolder & "$)"; case-insensitive, match from first char, terminate strings
    EndIf
    ; Edit exclude files list
    If $sExclude Then
        $sExclude = StringRegExpReplace(StringRegExpReplace($sExclude, "(s*;s*)+", ";"), "A;|;z", "") ; Strip unwanted whitespace
        $sExclude = StringRegExpReplace($sExclude, "[][$.+^{}()]", "$0"); Ignore special characters
        $sExclude = StringReplace(StringReplace(StringReplace($sExclude, "?", "."), "*", ".*?"), ";", "$|") ; Convert ?=.  *=.*?  ;=|
        $sExclude = "(?i)A(?!" & $sExclude & "$)"; case-insensitive, match from first char, terminate strings
    EndIf
;   MsgBox(1,"Masks","File include: " & $sInclude & @CRLF & "File exclude: " & $sExclude & @CRLF & "Dir exclude : " & $sExcludeFolder)[/size]

    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
    Local $sOrigPathLen = StringLen($sPath), $aQueue[64] = [1,$sPath], $iQMax = 63
    While $aQueue[0]
        $WorkFolder = $aQueue[$aQueue[0]]
        $aQueue[0] -= 1
        $search = FileFindFirstFile($WorkFolder & "*")
        If @error Then ContinueLoop
        Switch $iPathType
            Case 1 ; relative path
                $sReturnFormat = StringTrimLeft($WorkFolder, $sOrigPathLen)
            Case 2 ; full path
                $sReturnFormat = $WorkFolder
        EndSwitch
        While 1
            $file = FileFindNextFile($search)
            If @error Then ExitLoop
            If @extended Then ; Folder
                If $sExcludeFolder And Not StringRegExp($file, $sExcludeFolder) Then ContinueLoop
                If $bRecursive Then
                    If $aQueue[0] = $iQMax Then
                        $iQMax += 128
                        ReDim $aQueue[$iQMax + 1]
                    EndIf
                    $aQueue[0] += 1
                    $aQueue[$aQueue[0]] = $WorkFolder & $file & ""
                EndIf
                If $iFlag = 1 Then ContinueLoop
             $sRet &= $sReturnFormat & $file & "|"
            Else ; File
                If $iFlag = 2 Then ContinueLoop
    If $sInclude And Not StringRegExp($file, $sInclude) Then ContinueLoop
    If $sExclude And Not StringRegExp($file, $sExclude) Then ContinueLoop
    $sRet &= $sReturnFormat & $file & "|"
            EndIf
        WEnd
        FileClose($search)
    WEnd
    If Not $sRet Then Return SetError(4, 4, "")
    Return StringSplit(StringTrimRight($sRet, 1), "|")
EndFunc

edit: fixed screwed up code tags (repeatedly)

Edited by Spiff59
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...