Kopiervorgang mit Prozentangabe und Dateien

  • Hallo Zusammen,

    ich habe eine Frage, wie ich einen Kopiervorgang angehe:

    Mein Vorhaben bzw. Ziel:
    Ich möchte gerne einen Ordner in ein Ziel kopieren. _copy("C:\test\quelle\","C:\test\ziel\")
    Die bereits vorhanden Dateien bzw. Ordner dürfen nur überschrieben werden, wenn die Quelle neuer ist.
    Es muss eine Prozentangabe und ein Prozessbalken geben.
    Extra: Man sieht, welche Datei gerade kopiert wird
    Extra: Man sieht die Kopiergeschwindigkeit
    Extra: Man sieht die noch verbleibende Zeit

    Folgende Sachen habe ich bereits ausprobiert:

    Spoiler anzeigen
    [autoit]


    $winShell = ObjCreate("shell.application")
    $winShell.namespace($ziel).CopyHere($quelle,$FOF_SIMPLEPROGRESS)

    [/autoit]


    Leider weiß ich hier nicht, wie ich sagen kann, dass nur neuere Dateien kopiert werden sollen.
    (wäre aber mal nützlich zu wissen, wenn einer Ahnung davon hat ^^)
    Außerdem ist es ungeeignet, da ich eine eigene GUI erzeugen möchte, wo es einen Prozessbalken gibt :)

    --------------------------------------------------------------------------------------------------------

    Spoiler anzeigen
    [autoit]


    $callback = DllCallbackRegister ( "Progress" , "int", "uint64;uint64;uint64;uint64;dword;dword;hwnd;hwnd;ptr")
    $ptr = DllCallbackGetPtr ( $callback )

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

    GUICtrlSetData($Label2,$sourcefile)
    GUICtrlSetData($Label5,$destinationfile)
    $Timer = TimerInit()
    DllCall("kernel32.dll", "int", "CopyFileExA", "str" , $sourcefile , "str", $destinationfile, "ptr", $ptr , "ptr", 0, "int", 0, "int", 0)
    ;~ ProgressOff ()
    Sleep(500)
    GUIDelete()
    Func Progress($TotalFileSize, $TotalBytesTransferred, $StreamSize, $StreamBytesTransferred, $dwStreamNumber, $dwCallbackReason, $hSourceFile, $hDestinationFile, $lpData)
    ;~ If GUIGetMsg() = $Button1 Then Return 1 ; Cancel Copying NICHT MIT GUIGetMSg arbeiten !!!, auch Sleeps nicht machen...
    ; Button State so verwenden :::
    If BitAND(_GUICtrlButton_GetState(GUICtrlGetHandle($Button1)),$BST_PUSHED) = $BST_PUSHED Then Return 1
    ;~ If WinActive($Form1) And _IsPressed("1B") Then Return 1

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

    Local $percDone = round($TotalBytesTransferred/$TotalFileSize * 100, 0)
    GUICtrlSetData($Label9,$TotalBytesTransferred & " Bytes from " & $TotalFileSize)
    GUICtrlSetData($Label7,Round((TimerDiff($Timer)/$percDone)*(100-$percDone)/1000,1) & "s") ; Millisekunden pro Prozent * RestProzent / 1000 ( damit Skeunden rauskommen )
    GUICtrlSetData($Progress1,$percDone); , round($TotalBytesTransferred/$TotalFileSize * 100, 0) & "%")

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

    EndFunc

    [/autoit]


    Hier habe ich das Problem, dass ich bis jetzt nur Datei zu Datei und nicht Ordner zu Ordner übertragen kann... aber wir kommen der Sache näher :)

    ---------------------------------------------------------------------------------------------------------

    Nun kommt das Programm aus diesem Forum. Ich glaube Oscar hat es geschrieben:
    https://autoit.de/index.php?page=Thread&threadID=7923
    Hier stellt sich die Frage, wie ich es umschreiben kann bzw. meine Anforderungen damit realisieren kann.
    Bis jetzt habe ich lediglich die INI-Datei fertig geschrieben. Sie sieht so aus:

    Spoiler anzeigen


    Somit liest das Script die einzelnen Pfade ein und führt ein Backup aus.
    Das Problem werden die Anzeigen mit einem Prozessbalken. Da müsste man Zwei haben.
    Aber ich weiß leider nicht, wie ich sowas realisieren kann :(
    Zudem habe ich ja meine eigene GUI, wo es Prozessbalken und Anzeigefelder für die Zeit und so geben wird (noch nicht erstellt)
    Und das Script legt mir eine Datei in das Verzeichnis, welche ich nicht haben möchte, bzw. brauche, da das Verzeichnis sich immer ändert.

    Ich hoffe, man kann mir helfen... Vielen Dank im Voraus erst einmal... die Anna

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

    2 Mal editiert, zuletzt von AnnaM (28. November 2012 um 11:12)

  • Zitat

    Die bereits vorhanden Dateien bzw. Ordner dürfen nur überschrieben werden, wenn die Quelle neuer ist.


    Mit

    [autoit]

    FileGetTime()

    [/autoit]

    Kannst du gucken wann die Datei das letzte mal bearbeitet wurde bzw wann sie erstellt wurde. Das kannst du in ein Array schreiben.

    Am besten packst du die Namen der Dateienb im Ordner in ein Array, sowie die größe und das Erstellungsdatum.

    Zitat

    Es muss eine Prozentangabe und ein Prozessbalken geben.


    Einfach gucken wv. Dateien im Ordner liegen (Ubound ($aFiles), $aFiles erstellst du mit

    [autoit]

    _FileListToArray()

    [/autoit]

    )

    Und dann:
    (100 / Ubound ($aFiles)) * $Anzahl_Der_kopierten_Dateien

    Dadurch bekommst du die %, wv schon kopiert wurde (In Anzahl, nicht in Größe der Dateien aufgeteilt.)

  • Und das Script legt mir eine Datei in das Verzeichnis, welche ich nicht haben möchte, bzw. brauche, da das Verzeichnis sich immer ändert.

    Du solltest das mit der INI mit den Windows Umgebnugsvariablen arbeiten damit kann man das ganze Flexibler handhaben. Da du sowieso eine GUI baust wird ich es so machen damit dir die Ordner in der GUI auswählen kannst die gesichert werden sollen! Wenn du die INI nicht willst schreib doch in der Registrie in der HKCU so kann jeder User auf dein PC in sein Profil seine eignen einstellungen machen ergibt mehr sinn als die INI

    Gruss DevFly

  • Hallo DevFly,

    danke für deinen Beitrag.
    Ich habe die INI erstellt, da manche Umgebungsvariablen nicht für alle Betriebssysteme gelten und man bei einem Registryeintrag nicht einfach das Programm und die zugehörigen Ordner löschen kann. Folglich müsste ich noch eine Deinstallation schreiben. Und so habe ich auch die Möglichkeit die INI schnell und unkompliziert zu editieren. :) Also werde ich das wohl erst einmal mit der INI weiter machen. Trotzdem ein netter Vorschlag. Danke.

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

  • Vielleicht gibt es noch jemanden, der eine idee oder ein gutes Script zur Umsetzung hat...

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

  • Hallo Anna,

    mit folgendem Script erhälst Du aus Deiner ini ein Array aller Files/Folders
    die in Deiner ini stehen.
    Der 2. Wert gibt die jeweilige Größe der Datei an und in $aFiles[0][1] steht die Gesamtanzahl an Bytes.
    Diese Angabe brauchst Du dann für Deinen Fortschrittbalken.

    Schöner wäre es, wenn die List-Funktion gleich die Dateigröße auslesen würde.
    Dazu hatte ich aber jetzt keine Lust das umzubauen ... ;)

    Ich hab Deine Ini etwas umgebaut, da es keinen Grund gibt das in mehrere Sektionen zu verteilen.
    Wenn doch, dann kannst Du das ja anpassen :D

    Script:

    FileListToArrayXT
    [autoit]

    #include<Array.au3>
    Global $aIniRead = IniReadSection('backup.ini', 'BackupVerzeichnisse')
    Global $aTempFiles[1], $aFiles[1][2], $k

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

    For $i = 1 To $aIniRead[0][0]
    $aTemp = _FileListToArrayXT($aIniRead[$i][1], Default, 0 , 2, True, 0)
    $aTemp[0] = $aIniRead[$i][1]
    _ArrayConcatenate($aTempFiles, $aTemp)
    $aTempFiles[0] += UBound($aTemp)
    Next

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

    ReDim $aFiles[$aTempFiles[0]+1][2]

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

    For $i = 0 To $aTempFiles[0]
    $aFiles[$i][0] = $aTempFiles[$i]
    $k = FileGetSize($aTempFiles[$i])
    $aFiles[$i][1] = $k
    $aFiles[0][1] += $k
    Next

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

    _ArrayDisplay($aFiles)

    [/autoit] [autoit][/autoit] [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]


    und die von mir verwendete ini:

    Backup-ini
    [autoit]

    [BackupVerzeichnisse]
    ;FileZilla
    1 = C:\Users\Anna\Anwendungsdaten\FileZilla
    ; Trillian
    2 = C:\Program Files (x86)\Trillian
    ; Webentwicklung
    3 = E:\Webentwicklung
    ; Spiele
    4 = E:\Spiele
    ; Fonts
    5 = C:\Windows\Fonts
    ; Windows Sidebar
    6 = C:\Users\Anna\AppData\Local\Microsoft\Windows Sidebar
    ; FF-Hauptverzeichniss
    7 = C:\Program Files (x86)\Mozilla Firefox
    ; FF-Anwendungsdaten
    8 = C:\Users\Anna\Anwendungsdaten\Mozilla
    ; TB-Hauptverzeichniss
    9 = C:\Program Files (x86)\Mozilla Thunderbird
    ; TB-Anwendungsdaten
    10 = C:\Users\Anna\Anwendungsdaten\Thunderbird

    [/autoit]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

  • Hallo Schnuffel,

    danke für deine Mühe. Das Auslesen aus einer INI ist nun klar und auch sehr verständlich. Mir kommt es im Wesentlichen auf das Kopieren an sich an. Vor allem auf Schnelligkeit des Vorgangs wie auch das visuelle Anzeigen mit einem Prozessbalken und ähnlichen. Ich hoffe, dass du mir da auch helfen könntest. Ich finde den "_MultiFileCopy" hier im Forum super. Weiß aber nicht genau, wie ich diesen zu integrieren habe.

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

  • so,
    weil ich gerade Lust dazu hatte...

    Spoiler anzeigen
    [autoit]

    #include<Array.au3>
    #include <GUIConstants.au3>
    HotKeySet("!b", "_StopCopy")

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

    Global $GuiWidth = 500, $GuiHeight = 180, $aBpS, $byteCount = 0, $timer, $temp, $i, $MyStop
    $mainGui = GUICreate('Copy-Tool', $GuiWidth, $GuiHeight)

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

    $lStop = GUICtrlCreateLabel('', 10, 10, $GuiWidth-20, 20)
    GUICtrlSetFont(-1, 12,600)
    GUICtrlCreateLabel('Datei wird kopiert: ', 10, $GuiHeight -140, 100, 20)
    $Aktuell = GUICtrlCreateLabel('', 10, $GuiHeight -120, $GuiWidth -20, 18)
    GUICtrlCreateLabel('Fortschritt:', 10, $GuiHeight-100, 50, 20)
    $Anzahl = GUICtrlCreateLabel('0/0', 70, $GuiHeight -100, 80, 20)
    GUICtrlCreateLabel('Geschwindigkeit: ', 220, $GuiHeight-100, 80, 20)
    $Speed = GUICtrlCreateLabel('0 MB/s', 310, $GuiHeight -100, 80, 20)
    $mainProgress = GUICtrlCreateProgress(10, $GuiHeight-80, $GuiWidth-20, 20)
    $bStart = GUICtrlCreateButton('Kopiervorgang starten', 10 , $GuiHeight-50, $GuiWidth-20, 40)
    GUICtrlSetState($bStart, $GUI_DISABLE)
    GUISetState()

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

    $aCopyFiles = _FileRead(IniReadSection('backup.ini', 'BackupVerzeichnisse'))
    GUICtrlSetData($Anzahl, '0 / ' & $aCopyFiles[0][0])
    $aCopyPfad = IniRead('test.ini', 'Zielpfad', '1', '')

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

    GUICtrlSetState($bStart, $GUI_ENABLE)

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

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    Case $msg = $bStart
    GUICtrlSetData($lStop, 'Kopiervorgang läuft ...')
    GUICtrlSetData($bStart, 'Kopiervorgang läuft! -- beenden = Alt-b')
    $timer = TimerInit()
    For $i = 1 To $aCopyFiles[0][0]
    If $MyStop Then
    $MyStop = 0
    GUICtrlSetData($lStop, 'Kopiervorgang abgebrochen')
    ExitLoop
    EndIf
    GUICtrlSetData($Anzahl, $i & ' / ' & $aCopyFiles[0][0])
    GUICtrlSetData($Aktuell, $aCopyFiles[$i][0])
    If $aCopyFiles[$i][1] = 0 Then
    DirCreate($aCopyPfad & StringTrimLeft($aCopyFiles[$i][0],2))
    Else
    _FileCopy()
    EndIf
    GUICtrlSetData($mainProgress, 100/$aCopyFiles[0][1]*$byteCount)
    Next
    GUICtrlSetData($bStart, 'Kopiervorgang neu starten')
    GUICtrlSetState($bStart, $GUI_ENABLE)
    EndSelect
    WEnd

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

    Func _StopCopy()
    $MyStop = 1
    GUICtrlSetData($lStop, 'Kopiervorgang wird abgebrochen ...')
    EndFunc

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

    Func _FileCopy()
    FileCopy($aCopyFiles[$i][0], $aCopyPfad & StringTrimLeft($aCopyFiles[$i][0],2),9)
    $byteCount += $aCopyFiles[$i][1]
    $aBpS = Round($byteCount/(Round(TimerDiff($timer)/1000,0))/1048576,2)
    If $aBpS > 0 Then GUICtrlSetData($Speed, $aBpS & ' MB/s')
    EndFunc

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

    Func _FileRead($aMyFolders)
    Local $aTempFiles[1], $aFiles[1][2], $aTemp, $k
    For $i = 1 To $aMyFolders[0][0]
    $aTemp = _FileListToArrayXT($aMyFolders[$i][1], Default, 0 , 2, True, 0)
    $aTemp[0] = $aMyFolders[$i][1]
    _ArrayConcatenate($aTempFiles, $aTemp)
    $aTempFiles[0] += UBound($aTemp)
    Next
    ReDim $aFiles[$aTempFiles[0]+1][2]
    For $i = 0 To $aTempFiles[0]
    $aFiles[$i][0] = $aTempFiles[$i]
    $k = FileGetSize($aTempFiles[$i])
    $aFiles[$i][1] = $k
    $aFiles[0][1] += $k
    Next
    Return $aFiles
    EndFunc

    [/autoit] [autoit][/autoit] [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]

    Ach ja, die Ini-Datei habe ich um einen Backup-Pfad erweitert...

    Inidatei
    [autoit]

    [BackupVerzeichnisse]
    ;FileZilla
    1 = C:\Users\Anna\Anwendungsdaten\FileZilla
    ; Trillian
    2 = C:\Program Files (x86)\Trillian
    ; Webentwicklung
    3 = E:\Webentwicklung
    ; Spiele
    4 = E:\Spiele
    ; Fonts
    5 = C:\Windows\Fonts
    ; Windows Sidebar
    6 = C:\Users\Anna\AppData\Local\Microsoft\Windows Sidebar
    ; FF-Hauptverzeichniss
    7 = C:\Program Files (x86)\Mozilla Firefox
    ; FF-Anwendungsdaten
    8 = C:\Users\Anna\Anwendungsdaten\Mozilla
    ; TB-Hauptverzeichniss
    9 = C:\Program Files (x86)\Mozilla Thunderbird
    ; TB-Anwendungsdaten
    10 = C:\Users\Anna\Anwendungsdaten\Thunderbird

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

    [ZielPfad]
    1 = D:\Backup

    [/autoit]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

    Einmal editiert, zuletzt von Schnuffel (18. September 2011 um 17:18)

  • Hey Schnuffel,

    danke für deine Mühe. Aber leider bekomm ich einen Fehler.. Mache ich etwas falsch? Ich habe es so rauskopiert und auch so die ini übernommen.

    (70) : ==> Subscript used with non-Array variable.:
    For $i = 1 To $aMyFolders[0][0]
    For $i = 1 To $aMyFolders^ ERROR

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

  • Hallo,

    da bin ich nochmals ^^ Wie ich das gerade sehe, werden immer alle Daten kopiert, oder?
    Oder habe ich den Code nicht verstanden :(
    Ich möchte ja nur die Dateien kopieren, die noch nicht gesichert worden sind und zudem die, welche seit dem letzten Backup geändert worden sind :)
    Also immer eine 1:1 copy ohne, dass alles immer und immer wieder kopiert werden muss... also nur die veränderten.. ginge das? oder ist dieses ein zu hoher Aufwand?

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

  • mach mal in der ini die Leerzeichen vor und nach dem Gleichheitszeichen weg.
    Es wird nicht überprüft, ob die Verzwichnisse existieren ...

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

  • Habe ich gemacht.. Immer noch der gleiche Fehler :(
    Ich habs wirklich nur bei dir rauskopiert.... Pfade stimmen alle..


    AAAAHHH, nun habe ichs.. du hast einmal backup.ini und test.ini geschrieben ^^... Ich probiere das gleich mal aus *Gggg*

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

  • Ohja, es funktioniert nun... Kann man auch anzeigen lassen, am Besten auch mit einem Prozessbalken, wie eine Datei kopiert wird? Praktisch bei großen Dateien. Damit man weiß, dass nichts hängen geblieben ist...Zum Beispiel bei Videos oder ähnlichem. Ich hatte in meiner GUI zwei Prozessbalken vorgesehen. *ggg*

    Hoffe ich mache das nicht zu kompliziert. Aber das wäre echt supi.

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko:

  • theoretisch geht das, aber dann wird der ganze Ablauf langsamer...
    Ich kenne nur die Möglichkeit, den Kopiervorgang extern in einer Dos-Box audführen zu lassen.
    Dann kann man anhand der Grösse der Datei eine "Hochrechnung" machen wie lange das dauert und dann im Sekundentakt den Progress aktualisieren.
    Leider kostet das erstellen einer DosBox bei vielen Dateien viel Zeit.
    Dadurch wird das Script bei vielen kleinen Dateien um den Faktor 10 langsamer...
    Ich möchte aber Bitten, dass Du Dich mal etwas mit der Materie selbst befasst.

    Ich hab ja gern einen Ansatz erstellt, aber das ganze Script erstellen will ich nicht ;)

    so, hier mal mein vorerst letzter Ansatz ...

    Spoiler anzeigen
    [autoit]

    #include<Array.au3>
    #include <GUIConstants.au3>
    HotKeySet("!b", "_StopCopy")

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

    Global $GuiWidth = 500, $GuiHeight = 220, $aBpS, $byteCount = 0, $timer, $temp, $i, $MyStop, $aktSourceFolder
    $mainGui = GUICreate('Copy-Tool', $GuiWidth, $GuiHeight)

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

    $lStop = GUICtrlCreateLabel('', 10, 10, $GuiWidth-20, 20)
    GUICtrlSetFont(-1, 12,600)
    GUICtrlCreateLabel('Datei wird kopiert: ', 10, $GuiHeight -180, 100, 20)
    $Aktuell = GUICtrlCreateLabel('', 10, $GuiHeight -160, $GuiWidth -20, 18)
    $subProgress = GUICtrlCreateProgress(10, $GuiHeight-130, $GuiWidth-20, 20)
    GUICtrlCreateLabel('Fortschritt:', 10, $GuiHeight-100, 50, 20)
    $Anzahl = GUICtrlCreateLabel('0/0', 70, $GuiHeight -100, 80, 20)
    GUICtrlCreateLabel('Geschwindigkeit: ', 220, $GuiHeight-100, 80, 20)
    $Speed = GUICtrlCreateLabel('0 MB/s', 310, $GuiHeight -100, 80, 20)
    $mainProgress = GUICtrlCreateProgress(10, $GuiHeight-80, $GuiWidth-20, 20)
    $bStart = GUICtrlCreateButton('Kopiervorgang starten', 10 , $GuiHeight-50, $GuiWidth-20, 40)
    GUICtrlSetState($bStart, $GUI_DISABLE)
    GUISetState()
    ConsoleWrite(IniReadSection('backup.ini', 'BackupVerzeichnisse') & @CRLF)

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

    $aCopyFiles = _FileRead(IniReadSection('backup.ini', 'BackupVerzeichnisse'))

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

    GUICtrlSetData($Anzahl, '0 / ' & $aCopyFiles[0][0])
    $aCopyPfad = IniRead('backup.ini', 'Zielpfad', '1', '')

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

    GUICtrlSetState($bStart, $GUI_ENABLE)

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

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    Case $msg = $bStart
    GUICtrlSetData($lStop, 'Kopiervorgang läuft ...')
    GUICtrlSetData($bStart, 'Kopiervorgang läuft! -- beenden = Alt-b')
    $timer = TimerInit()
    For $i = 1 To $aCopyFiles[0][0]
    If $MyStop Then
    $MyStop = 0
    GUICtrlSetData($lStop, 'Kopiervorgang abgebrochen')
    ExitLoop
    EndIf
    GUICtrlSetData($Anzahl, $i & ' / ' & $aCopyFiles[0][0])
    GUICtrlSetData($Aktuell, $aCopyFiles[$i][0])
    If $aCopyFiles[$i][1] = 0 Then
    $aktSourceFolder = $aCopyFiles[$i][0]
    $aktDestFolder = $aCopyPfad & StringTrimLeft($aCopyFiles[$i][0],2)
    DirCreate($aktDestFolder)
    Else
    ;_FileCopy()
    _FileCopyDOS()
    EndIf
    GUICtrlSetData($mainProgress, 100/$aCopyFiles[0][1]*$byteCount)
    Next
    GUICtrlSetData($bStart, 'Kopiervorgang neu starten')
    GUICtrlSetState($bStart, $GUI_ENABLE)
    EndSelect
    WEnd

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

    Func _StopCopy()
    $MyStop = 1
    GUICtrlSetData($lStop, 'Kopiervorgang wird abgebrochen ...')
    EndFunc

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

    Func _FileCopy()
    If FileExists($aCopyPfad & StringTrimLeft($aCopyFiles[$i][0],2)) = 0 Or FileGetSize($aCopyPfad & StringTrimLeft($aCopyFiles[$i][0],2)) <> $aCopyFiles[$i][1] Then
    FileCopy($aCopyFiles[$i][0], $aCopyPfad & StringTrimLeft($aCopyFiles[$i][0],2),9)
    $byteCount += $aCopyFiles[$i][1]
    $aBpS = Round($byteCount/(Round(TimerDiff($timer)/1000,0))/1048576,2)
    If $aBpS > 0 Then GUICtrlSetData($Speed, $aBpS & ' MB/s')
    EndIf
    EndFunc

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

    Func _FileCopyDOS()
    $aktDestFolder = $aCopyPfad & StringTrimLeft($aktSourceFolder,2)
    $ProcID = Run(@ComSpec & ' /c xcopy /D /H /Y /J "' & $aCopyFiles[$i][0] & '" "' & $aktDestFolder & '"', "", @SW_HIDE)
    $origfilesize = DirGetSize($aktSourceFolder)
    Do
    $copyfilesize = DirGetSize($aktDestFolder)
    $percent = Round($origfilesize/$copyfilesize*100)
    GUICtrlSetData($subprogress, $percent)
    Until ProcessExists($ProcID) = 0
    $byteCount += $aCopyFiles[$i][1]
    $aBpS = Round($byteCount/(Round(TimerDiff($timer)/1000,0))/1048576,2)
    If $aBpS > 0 Then GUICtrlSetData($Speed, $aBpS & ' MB/s')
    GUICtrlSetData($subprogress, 0)
    EndFunc

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

    Func _FileRead($aMyFolders)
    Local $aTempFiles[1], $aFiles[1][2], $aTemp, $k
    For $i = 1 To $aMyFolders[0][0]
    $aTemp = _FileListToArrayXT($aMyFolders[$i][1], Default, 0 , 2, True, 0)
    $aTemp[0] = $aMyFolders[$i][1]
    _ArrayConcatenate($aTempFiles, $aTemp)
    $aTempFiles[0] += UBound($aTemp)
    Next
    ReDim $aFiles[$aTempFiles[0]+1][2]
    For $i = 0 To $aTempFiles[0]
    $aFiles[$i][0] = $aTempFiles[$i]
    $k = FileGetSize($aTempFiles[$i])
    $aFiles[$i][1] = $k
    $aFiles[0][1] += $k
    Next
    Return $aFiles
    EndFunc

    [/autoit] [autoit][/autoit] [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]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

    Einmal editiert, zuletzt von Schnuffel (18. September 2011 um 21:41)

  • Oh, tut mir Leid, dass ich mich nicht mehr gemeldet habe.. Ich hatte soo viel zu tun *uff*
    Aber dafür kümmer ich mich morgen um mein Programm wieder.. blöde Arbeit.. macht nicht spass.. :(

    Die Anna :*

    "Wo kämen wir hin, wenn jeder sagte wo kämen wir hin, und niemand ginge, um zu sehen, wohin wir kämen, wenn wir gingen..." :wacko: