DOS-Suchfunktionen

  • Hier ein paar Funktionen um Ordner oder Dateien mittels DOS zu suchen.

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>

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

    $a = _FindFiles('notepad.exe')
    _ArrayDisplay($a)

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

    $a = _FindFiles('Neu *')
    _ArrayDisplay($a)

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

    $a = _GetAllFolders(@ScriptDir)
    _ArrayDisplay($a)

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

    $a = _GetAllFiles(@ScriptDir)
    _ArrayDisplay($a)

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

    $a = _GetFolders("System")
    _ArrayDisplay($a)

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

    Func _FindFiles($sFileName, $sStartPath = @HomeDrive)
    ;funkey 20.12.2009
    Local $line, $aFiles
    Local $cmd = 'dir /a /b /s "' & $sFileName & '"'
    Local $Pid = Run(@ComSpec & " /c " & $cmd, $sStartPath & "\", @SW_HIDE, 2)
    While 1
    $line &= StdoutRead($Pid, 0, 0)
    If @error Then ExitLoop
    WEnd
    $aFiles = StringSplit(StringTrimRight($line, 2), @CRLF, 3)
    If $aFiles[0] = "" Then Return SetError(1, 0, "")
    For $i = 0 To UBound($aFiles) - 1
    $aFiles[$i] = _OEMToAnsi($aFiles[$i])
    Next
    Return $aFiles
    EndFunc ;==>_FindFiles

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

    Func _GetAllFolders($sPath = @HomeDrive)
    ;funkey 04.12.2009
    Local $line, $aFolder
    Local $cmd = 'dir /ad /b /s'
    Local $Pid = Run(@ComSpec & " /c " & $cmd, $sPath & "\", @SW_HIDE, 2)
    While 1
    $line &= StdoutRead($Pid, 0, 0)
    If @error Then ExitLoop
    WEnd
    $aFolder = StringSplit($line, @CRLF, 3)
    If $aFolder[0] = "" Then Return SetError(1, 0, "")
    ReDim $aFolder[UBound($aFolder) - 1]
    For $i = 0 To UBound($aFolder) - 1
    $aFolder[$i] = _OEMToAnsi($aFolder[$i])
    Next
    Return $aFolder
    EndFunc ;==>_GetAllFolders

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

    Func _GetFolders($SearchPath, $sStartPath = @HomeDrive)
    ;funkey 23.12.2009
    Local $line, $aFolder
    Local $cmd = 'dir /ad /b /s "' & $SearchPath & '"'
    Local $Pid = Run(@ComSpec & " /c " & $cmd, $sStartPath & "\", @SW_HIDE, 2)
    While 1
    $line &= StdoutRead($Pid, 0, 0)
    If @error Then ExitLoop
    WEnd
    $aFolder = StringSplit($line, @CRLF, 3)
    If $aFolder[0] = "" Then Return SetError(1, 0, "")
    ReDim $aFolder[UBound($aFolder) - 1]
    For $i = 0 To UBound($aFolder) - 1
    $aFolder[$i] = _OEMToAnsi($aFolder[$i])
    Next
    Return $aFolder
    EndFunc ;==>_GetFolders

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

    Func _GetAllFiles($sPath = @HomeDrive, $sExt = "*.*")
    ;funkey 20.12.2009
    Local $line, $aFiles
    Local $cmd = 'dir /a-d /b /s ' & $sExt
    Local $Pid = Run(@ComSpec & " /c " & $cmd, $sPath & "\", @SW_HIDE, 2)
    While 1
    $line &= StdoutRead($Pid, 0, 0)
    If @error Then ExitLoop
    WEnd
    $aFiles = StringSplit($line, @CRLF, 3)
    If $aFiles[0] = "" Then Return SetError(1, 0, "")
    ReDim $aFiles[UBound($aFiles) - 1]
    For $i = 0 To UBound($aFiles) - 1
    $aFiles[$i] = _OEMToAnsi($aFiles[$i])
    Next
    Return $aFiles
    EndFunc ;==>_GetAllFiles

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

    Func _OEMToAnsi($sOEM)
    Local $a_AnsiFName = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sOEM, 'str', '')
    If @error = 0 Then $sAnsi = $a_AnsiFName[2]
    Return $sAnsi
    EndFunc ;==>_OEMToAnsi

    [/autoit]


    mfg funkey

  • Hab noch eine Funktion erstellt um schnell Ordner zu finden.

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>

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

    $a = _GetFolders("System")
    _ArrayDisplay($a)

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

    $a = _GetFolders("*32")
    _ArrayDisplay($a)

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

    $a = _GetFolders(@UserName)
    _ArrayDisplay($a)

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

    Func _GetFolders($SearchPath, $sStartPath = @HomeDrive)
    ;funkey 23.12.2009
    Local $line, $aFolder
    Local $cmd = 'dir /ad /b /s "' & $SearchPath & '"'
    Local $Pid = Run(@ComSpec & " /c " & $cmd, $sStartPath & "\", @SW_HIDE, 2)
    While 1
    $line &= StdoutRead($Pid, 0, 0)
    If @error Then ExitLoop
    WEnd
    $aFolder = StringSplit($line, @CRLF, 3)
    If $aFolder[0] = "" Then Return SetError(1, 0, "")
    ReDim $aFolder[UBound($aFolder) - 1]
    For $i = 0 To UBound($aFolder) - 1
    $aFolder[$i] = _OEMToAnsi($aFolder[$i])
    Next
    Return $aFolder
    EndFunc ;==>_GetFolders

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

    Func _OEMToAnsi($sOEM)
    Local $a_AnsiFName = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sOEM, 'str', '')
    If @error = 0 Then $sAnsi = $a_AnsiFName[2]
    Return $sAnsi
    EndFunc ;==>_OEMToAnsi

    [/autoit]