本帖最后由 夜猫猫 于 2011-8-16 11:45 编辑
DOS回显:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows :: Version XP010
-------------------------------------------------------------------------------
Started : Thu Aug 11 11:59:14 2011
Source = D:\活佛济公2\
Dest : G:\活佛济公2\
Files : *.*
Options : *.* /S /E /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
60 D:\活佛济公2\
Newer 146.1 m 活佛济公2.24.vcd.rmvb
0.0% 0.0% 0.0% 0.1% 0.1% 0.2% 0.2% 0.2% 0.3% 0.3%.............100%
New File 144.2 m 活佛济公2.25.vcd.rmvb 0.0% 0.0% 0.0% 0.1% 0.1% 0.2% 0.2% 0.3% 0.3% 0.3% 0.4%
% 中间很多删了已经能获取百分比,该怎么获取上面数值里的文件数. 文件大小. 文件名代码:
#include <Constants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("测试", 391, 343, 283, 137)
$Pic1 = GUICtrlCreatePic(@ScriptDir&"\1.BMP", 16, 0, 360, 217)
$Label1 = GUICtrlCreateLabel("文件总数: 个", 32, 232, 250, 17)
$Label2 = GUICtrlCreateLabel("剩余文件: 个", 216, 232, 250, 17)
$Label3 = GUICtrlCreateLabel("文件大小:", 32, 256, 80, 17)
$Label4 = GUICtrlCreateLabel("传输速度: MB/秒", 216, 256, 159, 17)
$Progress1 = GUICtrlCreateProgress(16, 280, 318, 16)
$Label5 = GUICtrlCreateLabel("% ", 340, 282, 25, 17)
$Progress2 = GUICtrlCreateProgress(16, 312, 358, 16)
$Label6 = GUICtrlCreateLabel("", 176, 314, 30, 16)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetFont(-1, 9, 800)
GUICtrlSetColor(-1, 0xff0080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$sourcedir = "D:\活佛济公2"
$destdir = "G:\活佛济公2"
$ourProcess = Run (@ComSpec & " /c " & 'robocopy.exe ' & $sourcedir & ' ' & $destdir & ' /E', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
While 1
If $ourProcess Then
$charsWaiting = StdoutRead($ourProcess)
FileWrite(@ScriptDir& "\1.txt",$charsWaiting)
If $charsWaiting Then
$currentRead = StdoutRead($ourProcess)
$percent = StringRegExp($currentRead, '([0-9]{1,3})(?:.[0-9]{1,3})(?:%)',3);获取百分比
If IsArray($percent) = 1 Then
GUICtrlSetData($Progress1 ,$percent[0])
GUICtrlSetData($Progress2, $percent[0])
GUICtrlSetData($Label5,$percent[0]&"% ")
GUICtrlSetData($Label6,$percent[0]&"% ")
EndIf
EndIf
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ProcessClose("robocopy.exe")
Exit
EndSwitch
WEnd
|