wenn der Fehler wirklich dort liegt, was nicht sicher ist, dann gibt es kein $StringSplit[5] ![]()
Edit: bei genauerem Hinsehen gibt es sogar schon kein $StringSplit[2] ![]()
wenn der Fehler wirklich dort liegt, was nicht sicher ist, dann gibt es kein $StringSplit[5] ![]()
Edit: bei genauerem Hinsehen gibt es sogar schon kein $StringSplit[2] ![]()
mal ein Ansatz zum dran rumspielen ![]()
ElseIf GUICtrlRead($Spaeter) = 1 Then
[/autoit][autoit][/autoit][autoit]WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
$Form1 = GUICreate("Form1", 230, 80, 1360, 750)
$Com = GUICtrlCreateLabel("computer wird in ", 8, 14, 84, 17)
$Her = GUICtrlCreateLabel("Label2", 92, 14, 124, 17)
$Abbrechen = GUICtrlCreateButton("Abbrechen", 88, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
GUISetState()
$Zeit = (GUICtrlRead($Sekunden) + GUICtrlRead($Minuten)*60)
Global $sek = @SEC
While $Zeit > 0
If $Zeit >= 0 Then
While Sleep(10)
If $sek <> @SEC Then ExitLoop
Switch GUIGetMSG()
Case $GUI_EVENT_Close
ExitLoop
Case $Abbrechen
ExitLoop
EndSwitch
WEnd
GUICtrlSetData($Her, "in " $Zeit & "sek heruntergefahren")
$sek = @SEC
$Zeit -= 1
ConsoleWrite($Zeit & @CRLF)
EndIf
WEnd
bei Dir muss nur einmal der Knoten platzen, dann verstehst Du das...
Um einer Variablen einen Wert zuzuweisen reicht eine Anweisung à la:
$Variable =
In Deinem Beispiel also:
Local $Variable
If GUICtrlRead($SS_GK_IN) <> '' Then $Variable = GUICtrlSetData($Label3, GUICtrlRead($SS_GK_IN)* GUICtrlRead($S_GE) & ' €')
If GUICtrlRead($SS_P_IN) <> '' Then $Variable = GUICtrlSetData($Label3, GUICtrlRead($SS_P_IN)* GUICtrlRead($S_GE) & ' €')
Den Inhalt von $Variable kannst Du wann auch immer in Deinem Code an beliebiger STelle ausgeben:
GuiCtrlSetData($hierhin, $Variable)
[/autoit]
...
ich denke das geht mit nur einem Button viel einfacher ...
ich denke, das Problem liegt erstmal in dem Aufbau Deines Scriptes.
I.d.R. hat man einen Button und wenn man den drückt erfolgt ine Aktion (oder eben viele Aktionen)
Du hast in deinem Script zig Button.
Wenn man Dir eine vernünftige Lösung präsentieren soll, dann müssen wir auch wissen was wann passieren soll.
Also genaue Beschreibung, was das Script machen soll...
mal quick and dirty ohne mecker ![]()
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form=c:\program files (x86)\autoit3\koda\forms\rechner.kxf
$Form1_1 = GUICreate("Angebotsrechner", 658, 625, 237, 137)
$Group1 = GUICtrlCreateGroup("Wareneinkauf", 8, 16, 537, 161)
$HEK = GUICtrlCreateLabel("Händler EK", 40, 48, 58, 17)
$VERSI = GUICtrlCreateLabel("Versicherung", 296, 48, 66, 17)
$UMW = GUICtrlCreateLabel("Umweltpauschale", 40, 80, 88, 17)
$VERSA = GUICtrlCreateLabel("Versandkosten", 296, 80, 75, 17)
$SK = GUICtrlCreateLabel("Sonstige Kosten", 40, 112, 81, 17)
$MWST = GUICtrlCreateLabel("MwSt. %", 296, 112, 45, 17)
$MAGE = GUICtrlCreateLabel("Marge %", 40, 144, 42, 17)
$VK = GUICtrlCreateLabel("Verkaufspreis", 296, 144, 68, 17)
$HEK_IN = GUICtrlCreateInput("", 192, 48, 65, 21)
$UMW_IN = GUICtrlCreateInput("", 192, 80, 65, 21)
$SK_IN = GUICtrlCreateInput("", 192, 112, 65, 21)
$MAGE_IN = GUICtrlCreateInput("", 192, 144, 65, 21)
$VERSI_IN = GUICtrlCreateInput("", 448, 48, 65, 21)
$VERSA_IN = GUICtrlCreateInput("", 448, 80, 65, 21)
$VK_OUT = GUICtrlCreateLabel("€", 448, 144, 66, 17)
$MWST_IN = GUICtrlCreateInput("", 448, 112, 65, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Stundenansatz", 8, 192, 537, 129)
$SS_P = GUICtrlCreateLabel("Stundensatz Privatkunde", 40, 224, 123, 17)
$SS_G = GUICtrlCreateLabel("Stundensatz Geschäftskunde", 40, 256, 144, 17)
$GES_H_GEPL = GUICtrlCreateLabel("Geplante Gesamtstundenzahl", 296, 224, 143, 17)
$SUMME_H = GUICtrlCreateLabel("Summe Stunden", 40, 288, 82, 17)
$SS_P_IN = GUICtrlCreateInput("", 192, 224, 65, 21)
$SS_GK_IN = GUICtrlCreateInput("", 192, 256, 65, 21)
$S_GE = GUICtrlCreateInput("", 448, 224, 65, 21)
$Label3 = GUICtrlCreateLabel("€", 448, 288, 66, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Anfahrtskosten", 8, 336, 537, 129)
$Label11 = GUICtrlCreateLabel("Kilometerpauschale", 40, 368, 96, 17)
$Label12 = GUICtrlCreateLabel("Anfahrtskilometer", 40, 400, 85, 17)
$GEP_ANZ_ANF = GUICtrlCreateLabel("Geplante Anzahl Anfahrten", 296, 368, 131, 17)
$Label14 = GUICtrlCreateLabel("Summe Anfahrten / Kilometer", 40, 432, 142, 17)
$KILO_P = GUICtrlCreateInput("", 192, 368, 65, 21)
$KILO_AN = GUICtrlCreateInput("", 192, 400, 65, 21)
$ANZ_FAHR = GUICtrlCreateInput("", 448, 368, 65, 21)
$H_Gesamt = GUICtrlCreateLabel("€", 448, 432, 66, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$UEBERN_WARE = GUICtrlCreateButton("Übernahme", 562, 136, 75, 25, 0)
$ERRECHNEN_WARE = GUICtrlCreateButton("Errechnen", 562, 88, 75, 25, 0)
$LEEREN_WARE = GUICtrlCreateButton("Leeren", 562, 40, 75, 25, 0)
$UEBERNAHME_STUNDEN = GUICtrlCreateButton("Übernahme", 562, 286, 75, 25, 0)
$ERRECHNEN_STUNDEN = GUICtrlCreateButton("Errechnen", 562, 246, 75, 25, 0)
$LEEREN_STUNDEN = GUICtrlCreateButton("Leeren", 562, 206, 75, 25, 0)
$UEBERNAHME_ANFAHRT = GUICtrlCreateButton("Übernahme", 562, 434, 75, 25, 0)
$ERRECHNEN_ANFAHRT = GUICtrlCreateButton("Errechnen", 562, 394, 75, 25, 0)
$LEEREN_ANFAHRT = GUICtrlCreateButton("Leeren", 562, 354, 75, 25, 0)
$Group4 = GUICtrlCreateGroup("Gesamtkostenaufstellung", 8, 480, 537, 129)
$Label5 = GUICtrlCreateLabel("Ware", 40, 512, 30, 17)
$Label6 = GUICtrlCreateLabel("Stunden", 40, 544, 44, 17)
$Label7 = GUICtrlCreateLabel("Anfahrten", 40, 576, 50, 17)
$Label8 = GUICtrlCreateLabel("Gesamtkosten", 296, 512, 72, 17)
$GES_KOSTEN_OUT = GUICtrlCreateLabel("€", 448, 512, 66, 17)
$WARE_OUT = GUICtrlCreateLabel("€", 192, 512, 74, 17)
$STUNDEN_OUT = GUICtrlCreateLabel("€", 192, 544, 74, 17)
$ANFAHRTEN_OUT = GUICtrlCreateLabel("€", 192, 576, 74, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ERRECHNEN_GESAMT = GUICtrlCreateButton("Errechnen", 562, 530, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ERRECHNEN_WARE
$wert01 = GUICtrlRead ($HEK_IN)
$wert02 = GUICtrlRead ($UMW_IN)
$wert03 = GUICtrlRead ($SK_IN)
$wert04 = GUICtrlRead ($MAGE_IN)
$wert05 = GUICtrlRead ($VERSI_IN)
$wert06 = GUICtrlRead ($VERSA_IN)
$wert07 = GUICtrlRead ($MWST_IN)
GUICtrlSetData($VK_OUT, (( $wert01 + $wert02 + $wert03 + $wert05 + $wert06 ) + (( $wert01 + $wert02 + $wert03 + $wert05 + $wert06 ) / 100 * $wert04 )) + (( $wert01 + $wert02 + $wert03 + $wert05 + $wert06 ) / 100 * $wert07 ))
Case $UEBERN_WARE
GUICtrlSetData($WARE_OUT, (( $wert01 + $wert02 + $wert03 + $wert05 + $wert06 ) + (( $wert01 + $wert02 + $wert03 + $wert05 + $wert06 ) / 100 * $wert04 )) + (( $wert01 + $wert02 + $wert03 + $wert05 + $wert06 ) / 100 * $wert07 ))
Case $SUMME_H
$wert111 = GUICtrlRead ($SS_P_IN)
$wert222 = guictrlread ($SS_GK_IN)
$wert333 = GUICtrlRead ($S_GE)
Case $ERRECHNEN_STUNDEN
If GUICtrlRead($SS_P_IN) <> '' ANd GUICtrlRead($SS_GK_IN) <> '' Then
MsgBox(0, '', 'Bist Du verwirrt?')
GUICtrlSetData($SS_GK_IN, '')
GUICtrlSetData($SS_P_IN, '')
ContinueCase
EndIf
If GUICtrlRead($SS_GK_IN) <> '' Then GUICtrlSetData($Label3, GUICtrlRead($SS_GK_IN)* GUICtrlRead($S_GE) & ' €')
If GUICtrlRead($SS_P_IN) <> '' Then GUICtrlSetData($Label3, GUICtrlRead($SS_P_IN)* GUICtrlRead($S_GE) & ' €')
EndSwitch
WEnd
ein Script mit Deinem Ansatz würde echt weiterhelfen.
Nicht nur uns, sondern auch Dir ![]()
Not ist in diesem Fall eigentlich falsch, auch wenn es viele "Mißbrauchen".
Ich würde sicherer den realen Rückgabewert abfragen:
If FileExists(@ProgramFilesDir & "\CCleaner") = 0 Then
[/autoit]
Kann aber je nach BS variieren,
da das Makro @ProgramFilesDir je nach Kompilierung in 32-bit oder 64-bit einen anderen Wert annimmt ![]()
bitte schön:
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
; GUI verstecker ![]()
_meineInstallation()
EndSwitch
WEnd
Func _meineInstallation()
GUISetState(@SW_HIDE)
; Prüfen ob Verzeichnise für RegistryBackup existieren und ggf. anlegen
If Not FileExists("C:\RegistryBackup") Then
DirCreate("C:\RegistryBackup")
EndIf
If FileExists("C:\RegistryBackup\regbackup.reg") Then
FileDelete("C:\RegistryBackup\regbackup.reg")
EndIf
; Registry Backup
RunWait('regedit /e C:\RegistryBackup\regbackup.reg', @WindowsDir)
; Prüfung ob das Verzeichnis CCleaner im Programmverzeichnis von Windows existiert
If Not FileExists(@ProgramFilesDir & "\CCleaner") Then
; Download von Ccleaner
HttpSetProxy(0)
$url = "http://mm-edv.eu/DL/ccsetup310_slim.exe"
$filename = StringSplit($url, "/")
$filesplit = UBound($filename) - 1
InetGet($url, @WindowsDir & "\" & $filename[$filesplit])
; Installation von Ccleaner
ShellExecute("ccsetup310_slim.exe", '/S', @ProgramFilesDir & "\CCleaner", 'open', @SW_HIDE)
ElseIf FileExists(@ProgramFilesDir & "\CCleaner") Then
[/autoit] [autoit][/autoit] [autoit]ShellExecuteWait("C:\Program Files\CCleaner\CCleaner64.exe", "/AUTO")
EndIf
; Leeren der Windoof Temp-Ordner
FileDelete("C:\TEMP\*.*")
FileDelete("C:\Windows\Temp\*.*")
; Alles erledigt
[/autoit] [autoit][/autoit] [autoit]MsgBox(0, "Feddich", " Registry gesichert unter: C:\RegistryBackup und Festplatte sauber.")
Exit
EndFunc ;==>_meineInstallation
Exit
[/autoit]bitte schön:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
Dim $Code[2]
$Code[0] = '<table width="800" border="0" cellspacing="0" cellpadding="0">'& @CRLF &'<tr height="23">'& @CRLF &'<td valign="top" height="23" background="images/default/tabelle-oben.jpg">' & @CRLF _
&'<div align="center">'& @CRLF & '<table width="800" border="0" cellspacing="0" cellpadding="0" height="23">' & @CRLF & '<tr>'& @CRLF & '<td width="2"></td>'& @CRLF & '<td>'& @CRLF _
&'<div align="left">'&@CRLF& '<font color="black" face="Arial, Helvetica, sans-serif"><b>Top News vom' & @MDAY & "." & @MON & "." & @YEAR & '</b></font><b><font color="black" face="Arial, Helvetica, sans-serif" size="2"><br>'& @CRLF _
&'</font></b></div>'& @CRLF & '</td>'& @CRLF & '<td width="2"></td>'& @CRLF &'</tr>'& @CRLF &'</table>'& @CRLF &'</div>'& @CRLF &'</td>'& @CRLF &'</tr>'& @CRLF &'<tr><td valign="top" background="images/default/tabelle-mitte.jpg">'& @CRLF _
&'<div align="center">'& @CRLF & '<br>'& @CRLF & '<table width="800" border="0" cellspacing="2" cellpadding="0">'& @CRLF & '<tr><td valign="top" width="1">'& @CRLF & '<br>'& @CRLF & '</td>'& @CRLF & '<td valign="top" width="780">'& @CRLF _
&'<div align="left">'& @CRLF
$Code[1] = '</div>'& @CRLF & '</td>'& @CRLF & '<td valign="top" width="1"><br>'& @CRLF & '</td></tr></table></div></td></tr><tr height="23">'& @CRLF & '<td height="23" background="images/default/tabelle-oben.jpg"><br></td></tr></table><br>[1] >>'& @CRLF
#cs
HotKeySet("{Return}", "EnterWasPressed")
#ce
#Region ### START Koda GUI section ### Form=c:\users\standart\desktop\koda_1.7.3.0\forms\form1.kxf
$Form1_1 = GUICreate("Form1", 500, 339, -1, -1)
$Edit1 = GUICtrlCreateEdit("", 8, 96, 480, 200)
GUICtrlSetData(-1,"")
$Button1 = GUICtrlCreateButton("Speichern", 416, 304, 75, 25)
$Input1 = GUICtrlCreateInput("", 8, 40, 480, 21)
$Label1 = GUICtrlCreateLabel("Titel", 8, 8, 62, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Label2 = GUICtrlCreateLabel("Text", 8, 72, 38, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$file = FileOpen(@ScriptDir & "\news.txt", 2)
If $file = -1 Then Exit MsgBox(0, "Error", "Unable to open file.")
FileWrite($file,$Code[0])
FileWrite($file,'<p><b>' & GUICtrlRead ($Input1)& '<br>'& @CRLF & '<font size="2"><br><br>')
$aEdit1 = StringSplit(GUICtrlRead ($Edit1),@CRLF)
For $i = 1 To $aEdit1[0]
If $aEdit1[$i] <> '' Then FileWriteLine($file, '<font size="2"><br><br></font></b><font size="2">'&$aEdit1[$i]&'</font><b><font size="2"><br>')
Next
FileWrite($file,$Code[1])
FileClose($file)
EndSwitch
WEnd
#cs
Func EnterWasPressed()
GUICtrlSetState($edit1, Send('</font><b><font size="2"><br>')& @CRLF)
EndFunc
#ce
Ersatz-SuFu hat sich gemeldet, Wartungsintervall scheint noch nicht erreicht.
Ergo: Ist somit auch einsatzbereit. ![]()
upps, ich hab's übersehen...
Auch von mir Alles erdenklich Gute zum Geburtstag.
RunWait .....
oder
ShellExecuteWait
Das sind die Befehle der Stunde ![]()
Hallo Deepred92,
ich habe einen Bug in der portablen 3.3.0.1:
wenn ich nach dem Start die Lautstärke über das Menü im Systray verändern will kommt die Fehlermeldung:
Line 17599: Error: Unknown macro
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 ...
#include<Array.au3>
#include <GUIConstants.au3>
HotKeySet("!b", "_StopCopy")
Global $GuiWidth = 500, $GuiHeight = 220, $aBpS, $byteCount = 0, $timer, $temp, $i, $MyStop, $aktSourceFolder
$mainGui = GUICreate('Copy-Tool', $GuiWidth, $GuiHeight)
$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)
$aCopyFiles = _FileRead(IniReadSection('backup.ini', 'BackupVerzeichnisse'))
[/autoit] [autoit][/autoit] [autoit]GUICtrlSetData($Anzahl, '0 / ' & $aCopyFiles[0][0])
$aCopyPfad = IniRead('backup.ini', 'Zielpfad', '1', '')
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
Func _StopCopy()
$MyStop = 1
GUICtrlSetData($lStop, 'Kopiervorgang wird abgebrochen ...')
EndFunc
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
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
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
; #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
;[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]Local $aPath = StringSplit($sPath, ';', 1) ;paths array
Local $aFilter = StringSplit($sFilter, ';', 1) ;filters array
;---------------
[/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
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
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
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
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
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
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
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
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
EndFunc ;==>_FileListToArrayXT
[/autoit]mach mal in der ini die Leerzeichen vor und nach dem Gleichheitszeichen weg.
Es wird nicht überprüft, ob die Verzwichnisse existieren ...
so,
weil ich gerade Lust dazu hatte...
#include<Array.au3>
#include <GUIConstants.au3>
HotKeySet("!b", "_StopCopy")
Global $GuiWidth = 500, $GuiHeight = 180, $aBpS, $byteCount = 0, $timer, $temp, $i, $MyStop
$mainGui = GUICreate('Copy-Tool', $GuiWidth, $GuiHeight)
$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()
$aCopyFiles = _FileRead(IniReadSection('backup.ini', 'BackupVerzeichnisse'))
GUICtrlSetData($Anzahl, '0 / ' & $aCopyFiles[0][0])
$aCopyPfad = IniRead('test.ini', 'Zielpfad', '1', '')
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
Func _StopCopy()
$MyStop = 1
GUICtrlSetData($lStop, 'Kopiervorgang wird abgebrochen ...')
EndFunc
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
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
; #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
;[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]Local $aPath = StringSplit($sPath, ';', 1) ;paths array
Local $aFilter = StringSplit($sFilter, ';', 1) ;filters array
;---------------
[/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
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
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
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
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
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
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
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
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
EndFunc ;==>_FileListToArrayXT
[/autoit]Ach ja, die Ini-Datei habe ich um einen Backup-Pfad erweitert...
[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
[ZielPfad]
1 = D:\Backup
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 ![]()
Script:
#include<Array.au3>
Global $aIniRead = IniReadSection('backup.ini', 'BackupVerzeichnisse')
Global $aTempFiles[1], $aFiles[1][2], $k
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
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
_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
;[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]Local $aPath = StringSplit($sPath, ';', 1) ;paths array
Local $aFilter = StringSplit($sFilter, ';', 1) ;filters array
;---------------
[/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
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
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
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
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
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
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
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
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
EndFunc ;==>_FileListToArrayXT
[/autoit]
und die von mir verwendete ini:
[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
also bei mir funzt das so.
Ich hab Windows 7 64bit.
#RequireAdmin
$InstallDir_XP="C:\Programme\AutoIt3"
$InstallDir_W7="C:\Program Files (x86)\AutoIt3"
;~ Benutzer soll die Rechte zum Ändern bekommen
If @OSVersion = "WIN_XP" Then
RunWait(@ComSpec & ' /c cacls "' & $InstallDir_XP & '" /T /E /G Benutzer:F', '', @SW_SHOW)
Else
RunWait(@ComSpec & ' /c cacls "' & $InstallDir_W7 & '" /T /E /G Benutzer:F', '', @SW_SHOW)
EndIf