#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include #include #include ; Find all files (with or without an extension) in ScriptDir with recursion FindFiles("*", 1, False) Func FindFiles($filename, $recurse = 0, $CaseSensitive = False); ; v1.0 ; Find all files matching $filename with full wildcard support, including multiple * and ? usage. ; Set $recurse to 1 to include searching all subdirectories. ; Set $CaseSensitive to True to include case sensitive searching. ; Filenames without extension demand a $filename without an extension, ; e.g. abc* matches abc.txt and abc, whereas abc*.* matches abc.txt but not abc. ; ; Use Func FoundFileProcessing($filename) to process a single found file. ; FoundFileProcessing($filename) receives filenames with full path. ; ; AutoIt Version: 3.3.14.2 ; This function requires Windows 7 or later. ; ; Requirements to include in your main program: ; #include ; #include ; #include If $recurse = Default Then $recurse = 0 If $CaseSensitive = Default Then $CaseSensitive = False Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $ssDir = "", $sDummy1 = "", $sDummy2 = "" _PathSplit($filename, $sDrive, $sDir, $sFileName, $sExtension) ; extend path to full path if filename has no path or a path relative to ScriptDir If $sDrive = "" Then _PathSplit(@ScriptFullPath, $sDrive, $ssDir, $sDummy1, $sDummy2) $sDir = $ssDir & $sDir $filename = _PathMake($sDrive, $sDir, $sFileName, $sExtension) EndIf Local $hSearch $hSearch = FileFindFirstFile(_PathMake($sDrive, $sDir, "*", ".*")) ; searches for every file and directory If $hSearch = -1 Then Return 1 Local $pattern, $eExt, $pFileName $pattern = StringMid(_PathMake("", "", $sFileName, $sExtension), 2) ; StringMid skips leading \ While 1 $sFileName = FileFindNextFile($hSearch) If @error = 1 Then ; no more files or directories match the pattern ExitLoop Else $eExt = @extended $pFileName = _PathMake($sDrive, $sDir, $sFileName, "") ; _WinAPI_IsNameInExpression supports full wildcard matching, including multiple * and ? usage. If _WinAPI_IsNameInExpression($sFileName, $pattern, $CaseSensitive) Then FoundFileProcessing($pFileName) If $eExt = 1 And $recurse = 1 Then FindFiles($pFileName & '\' & $pattern, $recurse, $CaseSensitive) EndIf WEnd FileClose($hSearch) Return 1 ; no error EndFunc ;==>FindFiles Func FoundFileProcessing($filename) ConsoleWrite('processing ' & $filename & @CRLF) EndFunc ;==>FoundFileProcessing