_RecFileFinder(@ScriptDir & "\", "_Found", "*", "", 1) Func _Found($Path, $IsFolder) Select Case $IsFolder $FolderPath = StringSplit($Path,@CRLF,1) For $i = 1 To $FolderPath[0] $FolderName = StringSplit($FolderPath[$i],"\",1) MsgBox(0,"","Folder path"&@CRLF&$FolderPath[$i]) Next ; Case Else ConsoleWrite($Path & @CRLF) EndSelect EndFunc Func _RecFileFinder($sPath, $sFunction, $sInclude_List = "*", $sExclude_List = "", $fRecur = 0) Local $asFolderList[3] = [1], $sInclude_List_Mask, $sExclude_List_Mask Local $sCurrentPath, $hSearch, $sReturnPath = "", $sName, $fFolder ; Check valid path If Not FileExists($sPath) Then Return SetError(1, 1, "") ; Ensure trailing \ If StringRight($sPath, 1) <> "\" Then $sPath = $sPath & "\" ; Add path to folder list $asFolderList[1] = $sPath ; Determine Filter mask for SRE check If StringRegExp($sInclude_List, "\\|/|:|\<|\>|\|") Then Return SetError(1, 2, "") ; Check for invalid characters $sInclude_List = StringReplace(StringStripWS(StringRegExpReplace($sInclude_List, "\s*;\s*", ";"), 3), ";", "|") ; Strip WS and swap :/| $sInclude_List_Mask = "(?i)^" & StringReplace(StringReplace(StringReplace($sInclude_List, ".", "\."), "*", ".*"), "?", ".") & "\z" ; Convert to SRE pattern ; Determine Exclude mask for SRE check If $sExclude_List = "" Then $sExclude_List_Mask = ":" ; Set unmatchable mask Else If StringRegExp($sExclude_List, "\\|/|:|\<|\>|\|") Then Return SetError(1, 3, "") ; Check for invalid characters $sExclude_List = StringReplace(StringStripWS(StringRegExpReplace($sExclude_List, "\s*;\s*", ";"), 3), ";", "|") ; Strip WS and swap ;/| $sExclude_List_Mask = "(?i)^" & StringReplace(StringReplace(StringReplace($sInclude_List, ".", "\."), "*", ".*"), "?", ".") & "\z" ; Convert to SRE pattern EndIf ; Verify other parameter values If Not ($fRecur = 0 Or $fRecur = 1) Then Return SetError(1, 4, "") ; Search in listed Folders While $asFolderList[0] > 0 ; Set path to search $sCurrentPath = $asFolderList[$asFolderList[0]] ; Reduce folder array count $asFolderList[0] -= 1 ; Get search handle $hSearch = FileFindFirstFile($sCurrentPath & "*") ; If folder empty move to next in list If $hSearch = -1 Then ContinueLoop ; Search folder While 1 $sName = FileFindNextFile($hSearch) ; Check for end of folder If @error Then ExitLoop ; Check for subfolder - @extended set in 3.3.1.1 + $fFolder = @extended ;$fFolder = StringInStr(FileGetAttrib($sCurrentPath & $sName), "D") ; pre 3.3.1.1 ; If recursive search, add subfolder to folder list If $fRecur And $fFolder Then ; Increase folder array count $asFolderList[0] += 1 ; Double folder array size if too small (fewer ReDim needed) If UBound($asFolderList) <= $asFolderList[0] + 1 Then ReDim $asFolderList[UBound($asFolderList) * 2] ; Add subfolder to list $asFolderList[$asFolderList[0]] = $sCurrentPath & $sName & "\" Call($sFunction, $sCurrentPath & $sName, 1) EndIf ; Check file/folder type against required return value and file/folder name against Include/Exclude masks If Not $fFolder And StringRegExp($sName, $sInclude_List_Mask) And Not StringRegExp($sName, $sExclude_List_Mask) Then ;This is where you can do what you want with the found files Call($sFunction, $sCurrentPath & $sName, 0) EndIf WEnd ; Close current search FileClose($hSearch) WEnd EndFunc ;==>_RecFileFinder