#include #include #include #include #include Func readlog($logfilepath, ByRef $bytes, ByRef $lines) $bytes = 0 $logfile = FileOpen($logfilepath, 0) $lines = -1 ; number of files = number of lines in logfile -1 While 1 $line = FileReadLine($logfile) If @error Then ExitLoop $lines += 1 $position = StringInStr($line, @TAB, 0, -1) If $position > 0 Then $tmpbytes = StringLeft($line, $position - 1) $tmpbytes = StringStripWS($tmpbytes, 3) $tmpbytes = Int($tmpbytes) $bytes += $tmpbytes EndIf WEnd FileClose($logfile) EndFunc ;==>readlog Func robocopy($source, $destination, $logfilepath, $params) Local $totalbytes = 0 Local $totalfiles = 0 Local $donebytes = 0 Local $donefiles = 0 ; check if pathes end with a \ then remove it if StringRight($source,1) = "\" Then $source = StringLeft($source, StringLen($source)-1) if StringRight($destination,1) = "\" Then $destination = StringLeft($destination, StringLen($destination)-1) Switch $params Case "mirror" $params = "/mir /mt /np /ndl /nc /bytes /njh /njs /e" Case "copy" $params = "/mt /np /ndl /nc /bytes /njh /njs /e" EndSwitch RunWait(@ComSpec & ' /c ' & 'robocopy.exe "' & $source & '" "' & $destination & '" ' & $params & ' /log:"' & $logfilepath & '" /l', @TempDir, @SW_HIDE) readlog($logfilepath, $totalbytes, $totalfiles) if $totalbytes = 0 Then Exit $str_total_bytes = StringRegExpReplace($totalbytes, '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1.') $str_total_files = StringRegExpReplace($totalfiles, '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1.') ConsoleWrite("Gesamte Bytes: " & $str_total_bytes & @CRLF) ConsoleWrite("Gesamte Files: " & $str_total_files & @CRLF) $Form1 = GUICreate("RoboCopy GUI", 580, 180, 192, 124) GUICtrlCreateLabel("Quelle", 16, 12, 36, 17) $quelle = GUICtrlCreateInput("", 60, 8, 500, 21) GUICtrlSetState($quelle, $GUI_DISABLE) GUICtrlCreateLabel("Ziel", 16, 44, 36, 17) $ziel = GUICtrlCreateInput("", 60, 40, 500, 21) GUICtrlSetState($ziel, $GUI_DISABLE) $lbl_files = GUICtrlCreateLabel("", 16, 72, 560, 17) $Progress1 = GUICtrlCreateProgress(16, 88, 544, 25) $lbl_bytes = GUICtrlCreateLabel("", 16, 120, 560, 17) $Progress2 = GUICtrlCreateProgress(16, 136, 544, 25) GUISetState(@SW_SHOW) GUICtrlSetData($quelle, $source) GUICtrlSetData($ziel, $destination) FileDelete($logfilepath) $pid = Run(@ComSpec & ' /c ' & 'robocopy.exe "' & $source & '" "' & $destination & '" ' & $params & ' /log:"' & $logfilepath & '"', @TempDir, @SW_HIDE) While ProcessExists($pid) Sleep(500) readlog($logfilepath, $donebytes, $donefiles) $str_done_bytes = StringRegExpReplace($donebytes, '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1.') $str_done_files = StringRegExpReplace($donefiles, '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1.') $percent_bytes = $donebytes * 100 / $totalbytes $percent_files = $donefiles * 100 / $totalfiles ConsoleWrite("Erledigte Bytes: " & $str_done_bytes & ", entspricht : " & $percent_bytes & "%" & @CRLF) ConsoleWrite("Erledigte Files: " & $str_done_files & ", entspricht : " & $percent_files & "%" & @CRLF) GUICtrlSetData($Progress1, $percent_bytes ) GUICtrlSetData($Progress2, $percent_files) GUICtrlSetData($lbl_bytes, $str_done_bytes & " von " & $str_total_bytes & " (" & StringFormat("%.2f", $percent_bytes) & "%)") GUICtrlSetData($lbl_files, $str_done_files & " von " & $str_total_files & " (" & StringFormat("%.2f", $percent_files) & "%)") WEnd EndFunc ;==>robocopy robocopy("c:\test", "d:\x", @TempDir & "\robocopy.log", "copy")