HalliHallo!
Ich hatte irgendwie Lust eine Func zu schreiben, mit der man nach Dateien eines bestimmten Types suchen, oder einfach alle vorhandenen Dateien aufliste kann.
Ich weiß nicht ob es jemand gebrauchen kann, weil es ja auch noch eine Func mit rekursiver Suche gibt.
Aber ich bin jetzt einfach mal so frei und poste hier meine Func:
Spoiler anzeigen
; #VARIABLES# ===================================================================================================================
$List = ""
$I = 0
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name...........: _FTsearch
; Description ...: Search for file with a specified type.
; Syntax.........: _FTsearch([$Path,$FileT])
; Parameters ....: $Path - Location where to start the search from. Don't forget the ending '\'
; $FileT - Type of the files to search for. (Just the Type without wildcard or '.')
; Return values .: Success - List of files found
; Failure - Empty String
; Author ........: Lennart W. - Lenny @ Autoit.de
; Remarks .......: This Function searches for Files with a given Filetype or Lists all Files on the Pc, if $Path and $FileT are empty.
; Required.......: This Function requires _GetFileType
; Example .......; _FTSearch("C:\MyDir","jpg")
; ===============================================================================================================================
Func _FTSearch($Path = "C:\", $FileT = "*")
$Search = FileFindFirstFile($Path & "*.*")
While 1
$File = FileFindNextFile($Search)
If @error Then Return ($List)
If StringInStr(FileGetAttrib($Path & $File), "D") Then
_FTSearch($Path & $File & "\", $FileT)
Else
If StringInStr(_GetFileType($File) & "*", $FileT) Then
$I += 1
$List &= $I & ". " & $Path & $File & @CRLF
EndIf
EndIf
WEnd
FileClose($Search)
EndFunc ;==>_FTSearch
Func _GetFileType($lFile = "")
$ExtSplit = StringSplit($lFile, ".")
Return ($ExtSplit[UBound($ExtSplit) - 1])
EndFunc ;==>_GetFileType
Ich hoffe es kann jemand gebrauchen. Ich denke man könnte es auch ohne zuviel Aufwand in eine direkte Dateisuche umwandeln.
Lg,
Lenny