_FileListToArrayEx - Umlaute -.-

  • Hallo,

    ich habe mir einmal die _FileListToArrayEx Function von Xenobiologist kopiert.

    jetzt habe ich leider das Problem, das diese Funktion keine Umlaute erkennt. Also die Funktion ersetzt sie durch ein Rechteck.

    Jetzt wollte ich wissen ob man das irgendwie "umgehen" oder beheben kann?

    Ich bedanke mich jetzt schon einmal

  • loool, ok sorry :D

    ich weis nicht mehr so genau von wem ich diese Funktion habe, aber ich hätte mir gedacht das sie von dir sei.

    :rofl:

    Das ist mir jetzt aber schon irgendwie peinlich^^

    Naja sorry, ich weis es echt nicht mehr, aber ich schau mal nach.

    3 Mal editiert, zuletzt von morfi93 (25. Februar 2008 um 21:13)

  • ja, gute idee ^^

    hier:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    Func _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '')
    If Not FileExists($sPath) Then Return SetError(1, 1, '')
    If $sFilter = -1 Or $sFilter = Default Then $sFilter = '*.*'
    If $iFlag = -1 Or $iFlag = Default Then $iFlag = 0
    If $sExclude = -1 Or $sExclude = Default Then $sExclude = ''
    Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|']
    For $iCC = 0 To 5
    If StringInStr($sFilter, $aBadChar[$iCC]) Or _
    StringInStr($sExclude, $aBadChar[$iCC]) Then Return SetError(2, 2, '')
    Next
    If StringStripWS($sFilter, 8) = '' Then Return SetError(2, 2, '')
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, '')
    Local $oFSO = ObjCreate("Scripting.FileSystemObject"), $sTFolder
    $sTFolder = $oFSO.GetSpecialFolder(2)
    Local $hOutFile = @TempDir & $oFSO.GetTempName
    If Not StringInStr($sFilter, ';') Then $sFilter &= ';'
    Local $aSplit = StringSplit(StringStripWS($sFilter, 8), ';'), $sRead
    For $iCC = 1 To $aSplit[0]
    If StringStripWS($aSplit[$iCC], 8) = '' Then ContinueLoop
    If StringLeft($aSplit[$iCC], 1) = '.' And _
    UBound(StringSplit($aSplit[$iCC], '.')) - 2 = 1 Then $aSplit[$iCC] = '*' & $aSplit[$iCC]
    RunWait(@ComSpec & ' /c ' & 'dir "' & $sPath & '\' & $aSplit[$iCC] _
    & '" /b /o-e /od > "' & $hOutFile & '"', '', @SW_HIDE)
    $sRead &= FileRead($hOutFile)
    If Not FileExists($hOutFile) Then Return SetError(4, 4, '')
    FileDelete($hOutFile)
    Next
    If StringStripWS($sRead, 8) = '' Then SetError(4, 4, '')
    Local $aFSplit = StringSplit(StringTrimRight(StringStripCR($sRead), 1), @LF)
    Local $sHold
    For $iCC = 1 To $aFSplit[0]
    If $sExclude And StringLeft($aFSplit[$iCC], _
    StringLen(StringReplace($sExclude, '*', ''))) = StringReplace($sExclude, '*', '') Then ContinueLoop
    Switch $iFlag
    Case 0
    $sHold &= $aFSplit[$iCC] & Chr(1)
    Case 1
    If StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') Then ContinueLoop
    $sHold &= $aFSplit[$iCC] & Chr(1)
    Case 2
    If Not StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') Then ContinueLoop
    $sHold &= $aFSplit[$iCC] & Chr(1)
    EndSwitch
    Next
    If StringTrimRight($sHold, 1) Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1))
    Return SetError(4, 4, '')
    EndFunc

    [/autoit]
  • Hallo Zusammen,

    auch ich nutze diese tolleFunktion. Habe aber genau wie der Autor dass Problem dass Umlaute ausgefiltert werden. Habe schon einiges probiert aber bisher bin ich noch nicht drauf gekommen.

    Weiß jemand wieso Umlaute hier ausgefiltert werden?

    Danke schonmal und Grüße

    Alex

    [autoit]

    Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|']
    For $iCC = 0 To 5
    If StringInStr($sFilter, $aBadChar[$iCC]) Or _
    StringInStr($sExclude, $aBadChar[$iCC]) Then Return SetError(2, 2, '')
    Next

    [/autoit]

    Das versteh ich auch nicht ganz. Wieso werden solche Zeichen herausgefiltert

  • Hallo Nochmals,

    hab im Englischen Forum eine verbesserte Funktion gefunden:

    Fragt mich jetzt nur nicht wie das funktioniert aber es ist irre schnell und Umlaute werden mit genommen

    Grüße

    Alex

    [autoit]

    ; #FUNCTION# ===========================================================================================
    ; Name: _FileListToArrayXT
    ; Description: Lists files and\or folders in specified path(s) (Similar to using Dir with the /B Switch)
    ; additional features: multi-path, multi-filter, multi-exclude-filter, path format options, recursive search
    ; Syntax: _FileListToArrayXT([$sPath = @ScriptDir, [$sFilter = "*", [$iRetItemType, [$bRecursive = False, [$sExclude = "", [$iRetFormat = 1]]]]]])
    ; Parameter(s): $sPath = optional: Search path(s), semicolon delimited (default: @ScriptDir)
    ; (Example: "C:\Tmp;D:\Temp")
    ; $sFilter = optional: Search filter(s), semicolon delimited . Wildcards allowed. (default: "*")
    ; (Example: "*.exe;*.txt")
    ; $iRetItemType = Include in search: 0 = Files and Folder, 1 = Files Only, 2 = Folders Only
    ; $iRetPathType = Returned element format: 0 = file/folder name only, 1 = relative path, 2 = full path
    ; $bRecursive = optional: True: recursive search including all subdirectories
    ; False (default): search only in specified folder
    ; $sExclude = optional: Exclude filter(s), semicolon delimited. Wildcards allowed.
    ; (Example: "Unins*" will remove all files/folders that begin with "Unins")
    ; $iRetFormat = optional: return format
    ; 0 = one-dimensional array, 0-based
    ; 1 = one-dimensional array, 1-based (default)
    ; 2 = String ( "|" delimited)
    ; Requirement(s): AutoIt Version 3.3.1.1 or newer
    ; Return Value(s): on success: 1-based or 0-based array or string (dependent on $iRetFormat)
    ; If no path is found, @error and @extended are set to 1, returns empty string
    ; If no filter is found, @error and @extended are set to 2, returns empty string
    ; If $iRetFormat is invalid, @error and @extended are set to 3, returns empty string
    ; If no data is found, @error and @extended are set to 4, returns empty string
    ; Author(s): Half the AutoIt Community
    ; ====================================================================================================
    Func _FileListToArrayXT($sPath = @ScriptDir, $sFilter = "*", $iRetItemType = 0, $iRetPathType = 0, $bRecursive = False, $sExclude = "", $iRetFormat = 1)
    Local $hSearchFile, $sFile, $sFileList, $sWorkPath, $sRetPath, $iRootPathLen, $iPCount, $iFCount, $fDirFlag

    [/autoit][autoit][/autoit][autoit]

    ;[check and prepare parameters]
    ;---------------
    If $sPath = -1 Or $sPath = Default Then $sPath = @ScriptDir
    ;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons
    $sPath = StringRegExpReplace(StringRegExpReplace($sPath, "(\s*;\s*)+", ";"), "\A;|;\z", "")
    ;check that at least one path is set
    If $sPath = "" Then Return SetError(1, 1, "")
    ;-----
    If $sFilter = -1 Or $sFilter = Default Then $sFilter = "*"
    ;prepare filter
    ;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons
    $sFilter = StringRegExpReplace(StringRegExpReplace($sFilter, "(\s*;\s*)+", ";"), "\A;|;\z", "")
    ;check for invalid chars or that at least one filter is set
    If StringRegExp($sFilter, "[\\/><:\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
    If $bRecursive Then
    ;Convert $sFilter for Regular Expression
    $sFilter = StringRegExpReplace($sFilter, '([\Q\.+[^]$(){}=!\E])', '\\$1')
    $sFilter = StringReplace($sFilter, "?", ".")
    $sFilter = StringReplace($sFilter, "*", ".*?")
    $sFilter = "(?i)\A(" & StringReplace($sFilter, ";", "$|") & "$)" ;case-insensitive, convert ';' to '|', match from first char, terminate strings
    ;$sFilter = "(?i)\A" & StringReplace($sFilter, ";", "|") & "\z"
    EndIf
    ;-----
    If $iRetItemType <> "1" And $iRetItemType <> "2" Then $iRetItemType = "0"
    ;-----
    If $iRetPathType <> "1" And $iRetPathType <> "2" Then $iRetPathType = "0"
    ;-----
    $bRecursive = ($bRecursive = "1")
    ;-----
    If $sExclude = -1 Or $sExclude = Default Then $sExclude = ""
    If $sExclude Then
    ;prepare $sExclude
    ;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons
    $sExclude = StringRegExpReplace(StringRegExpReplace($sExclude, "(\s*;\s*)+", ";"), "\A;|;\z", "")
    ;Convert $sExclude for Regular Expression
    $sExclude = StringRegExpReplace($sExclude, '([\Q\.+[^]$(){}=!\E])', '\\$1')
    $sExclude = StringReplace($sExclude, "?", ".")
    $sExclude = StringReplace($sExclude, "*", ".*?")
    $sExclude = "(?i)\A(" & StringReplace($sExclude, ";", "$|") & "$)" ;case-insensitive, convert ';' to '|', match from first char, terminate strings
    ;$sExclude = "(?i)\A" & StringReplace($sExclude, ";", "|") & "\z"
    EndIf
    ;-----
    ;If $iRetFormat <> "0" And $iRetFormat <> "2" Then $iRetFormat = "1"
    If Not ($iRetItemType = 0 Or $iRetItemType = 1 Or $iRetItemType = 2) Then Return SetError(3, 3, "")
    ;---------------
    ;[/check and prepare parameters]

    [/autoit][autoit][/autoit][autoit]

    ;---------------

    [/autoit][autoit][/autoit][autoit]

    Local $aPath = StringSplit($sPath, ';', 1) ;paths array
    Local $aFilter = StringSplit($sFilter, ';', 1) ;filters array

    [/autoit][autoit][/autoit][autoit]

    ;---------------

    [/autoit][autoit][/autoit][autoit]

    If $bRecursive Then ;different handling for recursion (strategy: unfiltered search for all items and filter unwanted)

    [/autoit][autoit][/autoit][autoit]

    If $sExclude Then ;different handling dependent on $sExclude parameter is set or not

    [/autoit][autoit][/autoit][autoit]

    For $iPCount = 1 To $aPath[0] ;Path loop
    $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash
    If Not FileExists($sPath) Then ContinueLoop
    $iRootPathLen = StringLen($sPath) - 1

    [/autoit][autoit][/autoit][autoit]

    Local $aPathStack[1024] = [1, $sPath]

    [/autoit][autoit][/autoit][autoit]

    While $aPathStack[0] > 0
    $sWorkPath = $aPathStack[$aPathStack[0]]
    $aPathStack[0] -= 1
    ;-----
    $hSearchFile = FileFindFirstFile($sWorkPath & '*')
    If @error Then ContinueLoop
    ;-----
    Switch $iRetPathType
    Case 2 ;full path
    $sRetPath = $sWorkPath
    Case 1 ;relative path
    $sRetPath = StringTrimLeft($sWorkPath, $iRootPathLen + 1)
    EndSwitch
    ;-----
    Switch $iRetItemType
    Case 1
    While True ;Files only
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    $fDirFlag = @extended
    If $fDirFlag Then
    $aPathStack[0] += 1
    If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2]
    $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"
    ContinueLoop
    EndIf
    If StringRegExp($sFile, $sExclude) Then ContinueLoop
    If StringRegExp($sFile, $sFilter) Then
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    WEnd
    Case 2
    While True ;Folders only
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    $fDirFlag = @extended
    If StringRegExp($sFile, $sExclude) Then ContinueLoop
    If $fDirFlag Then
    $aPathStack[0] += 1
    If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2]
    $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"
    If StringRegExp($sFile, $sFilter) Then
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    EndIf
    WEnd
    Case Else
    While True ;Files and Folders
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    $fDirFlag = @extended
    If StringRegExp($sFile, $sExclude) Then ContinueLoop
    If $fDirFlag Then
    $aPathStack[0] += 1
    If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2]
    $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"
    EndIf
    If StringRegExp($sFile, $sFilter) Then
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    WEnd
    EndSwitch
    ;-----
    WEnd

    [/autoit][autoit][/autoit][autoit]

    FileClose($hSearchFile)

    [/autoit][autoit][/autoit][autoit]

    Next ;$iPCount - next path

    [/autoit][autoit][/autoit][autoit]

    Else ;If Not $sExclude

    [/autoit][autoit][/autoit][autoit]

    For $iPCount = 1 To $aPath[0] ;Path loop
    $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash
    If Not FileExists($sPath) Then ContinueLoop
    $iRootPathLen = StringLen($sPath) - 1

    [/autoit][autoit][/autoit][autoit]

    Local $aPathStack[1024] = [1, $sPath]

    [/autoit][autoit][/autoit][autoit]

    While $aPathStack[0] > 0
    $sWorkPath = $aPathStack[$aPathStack[0]]
    $aPathStack[0] -= 1
    ;-----
    $hSearchFile = FileFindFirstFile($sWorkPath & '*')
    If @error Then ContinueLoop
    ;-----
    Switch $iRetPathType
    Case 2 ;full path
    $sRetPath = $sWorkPath
    Case 1 ;relative path
    $sRetPath = StringTrimLeft($sWorkPath, $iRootPathLen + 1)
    EndSwitch
    ;-----
    Switch $iRetItemType
    Case 1
    While True ;Files only
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    If @extended Then
    $aPathStack[0] += 1
    If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2]
    $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"
    ContinueLoop
    EndIf
    If StringRegExp($sFile, $sFilter) Then
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    WEnd
    Case 2
    While True ;Folders only
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    If @extended Then
    $aPathStack[0] += 1
    If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2]
    $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"
    If StringRegExp($sFile, $sFilter) Then
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    EndIf
    WEnd
    Case Else
    While True ;Files and Folders
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    If @extended Then
    $aPathStack[0] += 1
    If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2]
    $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\"
    EndIf
    If StringRegExp($sFile, $sFilter) Then
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    WEnd
    EndSwitch
    ;-----
    WEnd

    [/autoit][autoit][/autoit][autoit]

    FileClose($hSearchFile)

    [/autoit][autoit][/autoit][autoit]

    Next ;$iPCount - next path

    [/autoit][autoit][/autoit][autoit]

    EndIf ;If $sExclude

    [/autoit][autoit][/autoit][autoit]

    Else ;If Not $bRecursive (strategy: filtered search for items)

    [/autoit][autoit][/autoit][autoit]

    If $sExclude Then ;different handling dependent on $sExclude parameter is set or not

    [/autoit][autoit][/autoit][autoit]

    For $iPCount = 1 To $aPath[0] ;Path loop

    [/autoit][autoit][/autoit][autoit]

    $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash
    If Not FileExists($sPath) Then ContinueLoop
    ;-----
    Switch $iRetPathType
    Case 2 ;full path
    $sRetPath = $sPath
    Case 1 ;relative path
    $sRetPath = ""
    EndSwitch

    [/autoit][autoit][/autoit][autoit]

    For $iFCount = 1 To $aFilter[0] ;filter loop
    ;-----
    $hSearchFile = FileFindFirstFile($sPath & $aFilter[$iFCount])
    If @error Then ContinueLoop
    ;-----
    Switch $iRetItemType
    Case 1 ;files Only
    While True
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    If @extended Then ContinueLoop ;bypass folder
    ;check for exclude files
    If StringRegExp($sFile, $sExclude) Then ContinueLoop
    $sFileList &= $sRetPath & $sFile & "|"
    WEnd
    Case 2 ;folders Only
    While True
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    If @extended Then ;bypass file
    ;check for exclude folder
    If StringRegExp($sFile, $sExclude) Then ContinueLoop
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    WEnd
    Case Else ;files and folders
    While True
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    ;check for exclude files/folder
    If StringRegExp($sFile, $sExclude) Then ContinueLoop
    $sFileList &= $sRetPath & $sFile & "|"
    WEnd
    EndSwitch
    FileClose($hSearchFile)
    Next ;$iFCount - next filter

    [/autoit][autoit][/autoit][autoit]

    Next ;$iPCount - next path

    [/autoit][autoit][/autoit][autoit]

    Else ;If Not $sExclude

    [/autoit][autoit][/autoit][autoit]

    For $iPCount = 1 To $aPath[0] ;Path loop

    [/autoit][autoit][/autoit][autoit]

    $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash
    If Not FileExists($sPath) Then ContinueLoop
    ;-----
    Switch $iRetPathType
    Case 2 ;full path
    $sRetPath = $sPath
    Case 1 ;relative path
    $sRetPath = ""
    EndSwitch

    [/autoit][autoit][/autoit][autoit]

    For $iFCount = 1 To $aFilter[0] ;filter loop
    ;-----
    $hSearchFile = FileFindFirstFile($sPath & $aFilter[$iFCount])
    If @error Then ContinueLoop
    ;-----
    Switch $iRetItemType
    Case 1 ;files Only
    While True
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    If @extended Then ContinueLoop ;bypass folder
    $sFileList &= $sRetPath & $sFile & "|"
    WEnd
    Case 2 ;folders Only
    While True
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    If @extended Then ;bypass file
    $sFileList &= $sRetPath & $sFile & "|"
    EndIf
    WEnd
    Case Else ;files and folders
    While True
    $sFile = FileFindNextFile($hSearchFile)
    If @error Then ExitLoop
    $sFileList &= $sRetPath & $sFile & "|"
    WEnd
    EndSwitch
    FileClose($hSearchFile)
    Next ;$iFCount - next filter

    [/autoit][autoit][/autoit][autoit]

    Next ;$iPCount - next path

    [/autoit][autoit][/autoit][autoit]

    EndIf ;If $sExclude

    [/autoit][autoit][/autoit][autoit]

    EndIf ;If $bRecursive

    [/autoit][autoit][/autoit][autoit]

    ;---------------

    [/autoit][autoit][/autoit][autoit]

    ;set according return value
    If $sFileList Then
    Switch $iRetFormat
    Case 2 ;return a delimited string
    Return StringTrimRight($sFileList, 1)
    Case 0 ;return a 0-based array
    Return StringSplit(StringTrimRight($sFileList, 1), "|", 2)
    Case Else ;return a 1-based array
    Return StringSplit(StringTrimRight($sFileList, 1), "|", 1)
    EndSwitch
    Else
    Return SetError(4, 4, "")
    EndIf

    [/autoit][autoit][/autoit][autoit]

    EndFunc ;==>_FileListToArrayXT

    [/autoit]
    • Offizieller Beitrag

    Warum benutz du nicht _FileListToArray, aus der Standart UDF?

  • Hallo Zusammen,

    bei der _FilelisttoArray() habe ich das "Problem" dass ich als Muster immer nur eines angeben kann. Wenn ich beispielsweise eine Playlist aus einem Ordner genrieren möchte dann muss ich ja mehrere Typen berücksichtige. Das Geht mit dieser Funktion wunderbar und keine Ahnung wieso aber die "_FileListToArrayXT" ist wirklich deutlich schneller als die _FileListToArray. Bei sehr großen Ordnern ein angenehmer Nebeneffekt :)

    Grüße

    Alex

    • Offizieller Beitrag

    Oscar

    [OT on]

    Deinen Spruch werde ich mir merken. Hab das eigentlich immer mit d geschrieben, bis ich ständig in den Arbeitsanweisungen meines Chef´s das ganze mit t gelesen habe. Dieser Blödsinn ist bei mir hängengeblieben. Da hab ich jetz was um Ihn zu ärgern. :rofl:
    [OT off]

    • Offizieller Beitrag

    Hallo,

    der Grund warum _FileListToArrayEx keine Umlaute anzeigt liegt daran das der Dir-Befehl die Zeichen im ASCII-Format zurückgibt und die Ausgabe erfolgt im ANSI-Format.

    So passt es wieder!

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Func _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '')
    If Not FileExists($sPath) Then Return SetError(1, 1, '')
    If $sFilter = -1 Or $sFilter = Default Then $sFilter = '*.*'
    If $iFlag = -1 Or $iFlag = Default Then $iFlag = 0
    If $sExclude = -1 Or $sExclude = Default Then $sExclude = ''
    Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|']
    For $iCC = 0 To 5
    If StringInStr($sFilter, $aBadChar[$iCC]) Or _
    StringInStr($sExclude, $aBadChar[$iCC]) Then Return SetError(2, 2, '')
    Next
    If StringStripWS($sFilter, 8) = '' Then Return SetError(2, 2, '')
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, '')
    Local $oFSO = ObjCreate("Scripting.FileSystemObject"), $sTFolder
    $sTFolder = $oFSO.GetSpecialFolder(2)
    Local $hOutFile = @TempDir & $oFSO.GetTempName
    If Not StringInStr($sFilter, ';') Then $sFilter &= ';'
    Local $aSplit = StringSplit(StringStripWS($sFilter, 8), ';'), $sRead
    For $iCC = 1 To $aSplit[0]
    If StringStripWS($aSplit[$iCC], 8) = '' Then ContinueLoop
    If StringLeft($aSplit[$iCC], 1) = '.' And _
    UBound(StringSplit($aSplit[$iCC], '.')) - 2 = 1 Then $aSplit[$iCC] = '*' & $aSplit[$iCC]
    RunWait(@ComSpec & ' /c ' & 'dir "' & $sPath & '\' & $aSplit[$iCC] _
    & '" /b /o-e /od > "' & $hOutFile & '"', '', @SW_HIDE)
    $sRead &= OemToChar(FileRead($hOutFile))
    If Not FileExists($hOutFile) Then Return SetError(4, 4, '')
    FileDelete($hOutFile)
    Next
    If StringStripWS($sRead, 8) = '' Then SetError(4, 4, '')
    Local $aFSplit = StringSplit(StringTrimRight(StringStripCR($sRead), 1), @LF)
    Local $sHold
    For $iCC = 1 To $aFSplit[0]
    If $sExclude And StringLeft($aFSplit[$iCC], _
    StringLen(StringReplace($sExclude, '*', ''))) = StringReplace($sExclude, '*', '') Then ContinueLoop
    Switch $iFlag
    Case 0
    $sHold &= $aFSplit[$iCC] & Chr(1)
    Case 1
    If StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') Then ContinueLoop
    $sHold &= $aFSplit[$iCC] & Chr(1)
    Case 2
    If Not StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') Then ContinueLoop
    $sHold &= $aFSplit[$iCC] & Chr(1)
    EndSwitch
    Next
    If StringTrimRight($sHold, 1) Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1))
    Return SetError(4, 4, '')
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Name: OemToChar
    ; Description: Wandelt einen ASCII- in einen ANSI-String
    ; Parameter(s): $szSrc = String der umgewandelt werden soll
    ; Requirement(s): keine
    ; Return Value(s): bei Erfolg: umgewandelter String
    ; bei Fehler: "" und @error = 1
    ; Author(s): bernd670
    ;
    ;===============================================================================
    Func OemToChar ($szSrc)
    ;~ Private Declare Function OemToChar Lib "user32.dll" Alias "OemToCharA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long

    [/autoit] [autoit][/autoit] [autoit]

    Local $strSrc = DllStructCreate("char[" & StringLen($szSrc) + 1 & "]")
    Local $strDst = DllStructCreate("char[" & StringLen($szSrc) * 2 + 1 & "]")
    DllStructSetData($strSrc,1,$szSrc)
    DllStructSetData($strDst,1,0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $lRetVal = DllCall("user32.dll", "long", "OemToChar", "ptr", DllStructGetPtr($strSrc), "ptr", DllStructGetPtr($strDst))
    If IsArray($lRetVal) And $lRetVal[0] = 1 Then
    Return SetError(0,0,DllStructGetData($strDst,1))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return SetError(1,0,"")
    EndFunc

    [/autoit]
  • Hallo,

    der Grund warum _FileListToArrayEx keine Umlaute anzeigt liegt daran das der Dir-Befehl die Zeichen im ASCII-Format zurückgibt und die Ausgabe erfolgt im ANSI-Format.

    So passt es wieder!

    Hallo miteinander,

    srry, dass ich den "alten" Thread nochmals aufwecken muss :) !

    Die erweiterte Funktion von bernd670 funktioniert echt super. Problem ist nur, dass die Funktion mir nur noch die Dateiname zurückgibt. Schön wäre es, wenn die Funktion den kompletten Pfad zurückgeben kann.

    Wäre das möglich? Wenn ja, könntest du mir sagen wo?

    Danke

    Gipsy

    • Offizieller Beitrag

    Die erweiterte Funktion von bernd670 funktioniert echt super. Problem ist nur, dass die Funktion mir nur noch die Dateiname zurückgibt. Schön wäre es, wenn die Funktion den kompletten Pfad zurückgeben kann.


    Das ist ja der Sinn der Funktion. Den Pfad hast du doch bereits übergeben - brauchst ihn also nur mit den Dateinamen verknüpfen.

  • Hallo,

    jein, das funktioniert nicht so!

    Wenn ich jetzt z.B: folgende Ordnerstruktur habe

    D:\Test 5

    • Datei: Präsentation1.pptx
    • Datei: Präsentation2.pptx
    • Unterordner: Test --> beinhaltet eine Datei => Test.txt

    Dann sieht die TEMP Datei so aus:

    Code
    Pr„sentation1.pptx
    Pr„sentation2.pptx
    Neuer Ordner


    Dabei fehlt jetzt aber die Test.txt!

    Aufrufen tue ich die Funktion so!

    Code
    $test = _FileListToArrayEx("D:\Test 5", "*.*")

    Ich möchte jetzt nicht die Ordner einzeln angeben (die obrige Funktion ohne Modifikationen kann es ja auch) ;)

    Lösung?
    Gipsy