|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『楼 主』:
[讨论] CMD 下进度条实用化的问题。[求精]
使用 LLM 解释/回答一下
经过目前的测试。。大家觉得好的话。请给我加分。呵呵
复制文件的进度条显示问题得到初步解决!
利用点: start /min copy 路径:\文件名 路径:\做多线程的运行。。
难点:获取硬盘拷贝文件的速率问题。
自己写了一个批处理做为测试,该值为每微妙/86000字节(值向上取整的结果)
注意,不同规格的硬盘有不同的结果。
需要大家自己测试。(自己已经解决,而且做为进度条提示就是评估复制时间)
算法思想。
1,利用 dir 指令获取 拷贝 文件的文件大小。
2,文件大小除去硬盘传输速率得到动画的延时时间
3,利用这个时间写动画。
我在下面的一楼里就直接把这个代码给出来了。
注:代码经过精简,省去了第一步。。(因为是算法嘛:)
Last edited by flyinspace on 2007-4-1 at 02:34 PM ]
After the current tests... If everyone thinks it's good, please give me extra points. Hehe
The progress bar display problem of copying files has been initially solved!
Advantage: start /min copy path:\file name path:\ to run in multi-threaded way.
Difficulty: The problem of obtaining the hard disk copy file rate.
I wrote a batch file as a test, and this value is bytes per microsecond / 86000 (the result of rounding up).
Note that different specifications of hard disks have different results.
Need everyone to test by themselves. (I have solved it myself, and using it as a progress bar prompt is to estimate the copy time)
Algorithm idea.
1. Use the dir command to obtain the file size of the copied file.
2. Divide the file size by the hard disk transfer rate to get the delay time of the animation.
3. Use this time to write the animation.
I will directly give this code in the first floor below.
Note: The code is streamlined, and the first step is omitted.. (Because it's an algorithm :)
Last edited by flyinspace on 2007-4-1 at 02:34 PM ]
|

知,不觉多。不知,乃求知 |
|
2007-4-2 03:17 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
   『第 2 楼』:
先用一楼。一会发代码
使用 LLM 解释/回答一下
@echo off & SetLocal EnableDelayedExpansion
set BackSpace=
set RateBar=□
set Rate=0
set AllFile=1
set ExistFile=0
set FileName=测试.rar
set /a FileSize=42719467
set /a CopySpeed=86500
set /a UseTime=%FileSize%/%CopySpeed%
set /a ShowTime=%UseTime%/100
set Rate_Num=0
set Space_Num=11
set /p=正在拷贝文件:,需用时间:%UseTime%微秒<nul & echo.
echo ---------------------------------------------------
rem start /min FileName
set /p=目前已经完成: <nul
for /l %%i in (0,1,100) do (
set /a output=%%i%%10
if "!output!"=="0" (
rem echo The %%i Time
set /p=!BackSpace!<nul
set /a Space_Num=!Space_Num!-1
set /a Rate_Num=!Rate_Num!+1
call :PutChar !Rate_Num! !Space_Num!
)
if %%i LSS 10 set /p=: %%i%%<nul
if %%i GEQ 10 set /p=: %%i%%<nul
call :ProcDelay %ShowTime%
set /p=<nul
)
echo.
echo 拷贝已经完成!
echo.
goto EXIT
::::::::::::::输出空格:::::::::::::::::::::::
:PutChar _num_ _a_
for /l %%i in (1,1,%1) do (
rem echo !RateBar!
set /p=!RateBar!<nul
)
for /l %%i in (1,1,%2) do (
set /p= <nul
)
goto :EOF
::::::::::::::延时子程序:::::::::::::::::::::
:ProcDelay _Delay_
for /f "tokens=1-4 delims=:. " %%i in ("%time%") do set start=%%i%%j%%k%%l
:_TimeReturn_
for /f "tokens=1-4 delims=:. " %%i in ("%time%") do set end=%%i%%j%%k%%l
set /a s=%end%-%start%
if %s% LSS %1 goto _TimeReturn_
ENDLOCAL & GOTO :EOF
:EXIT
pause
Last edited by flyinspace on 2007-4-1 at 02:25 PM ]
@echo off & SetLocal EnableDelayedExpansion
set BackSpace=
set RateBar=□
set Rate=0
set AllFile=1
set ExistFile=0
set FileName=Test.rar
set /a FileSize=42719467
set /a CopySpeed=86500
set /a UseTime=%FileSize%/%CopySpeed%
set /a ShowTime=%UseTime%/100
set Rate_Num=0
set Space_Num=11
set /p=Copying file: , time required: %UseTime% microseconds<nul & echo.
echo ---------------------------------------------------
rem start /min FileName
set /p=Currently completed: <nul
for /l %%i in (0,1,100) do (
set /a output=%%i%%10
if "!output!"=="0" (
rem echo The %%i Time
set /p=!BackSpace!<nul
set /a Space_Num=!Space_Num!-1
set /a Rate_Num=!Rate_Num!+1
call :PutChar !Rate_Num! !Space_Num!
)
if %%i LSS 10 set /p=: %%i%%<nul
if %%i GEQ 10 set /p=: %%i%%<nul
call :ProcDelay %ShowTime%
set /p=<nul
)
echo.
echo Copy completed!
echo.
goto EXIT
::::::::::::::Output space:::::::::::::::::::::::
:PutChar _num_ _a_
for /l %%i in (1,1,%1) do (
rem echo !RateBar!
set /p=!RateBar!<nul
)
for /l %%i in (1,1,%2) do (
set /p= <nul
)
goto :EOF
::::::::::::::Delay subroutine:::::::::::::::::::::
:ProcDelay _Delay_
for /f "tokens=1-4 delims=:. " %%i in ("%time%") do set start=%%i%%j%%k%%l
:_TimeReturn_
for /f "tokens=1-4 delims=:. " %%i in ("%time%") do set end=%%i%%j%%k%%l
set /a s=%end%-%start%
if %s% LSS %1 goto _TimeReturn_
ENDLOCAL & GOTO :EOF
:EXIT
pause
|

知,不觉多。不知,乃求知 |
|
2007-4-2 03:17 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
其实,该代码不少代码都是借鉴别人的。
例如延时子程序。(作者未知)
但其他的则是根据c++里面的算法。。
利用set /p的特性完成的。。
这个程序和网上已经有的进度条不同。。
是可以实用化的。
In fact, many codes in this are borrowed from others.
For example, the delay subroutine. (Author unknown)
But others are based on the algorithms in C++.
It is completed by using the characteristics of set /p.
This program is different from the progress bars already available on the Internet.
It is practical.
|

知,不觉多。不知,乃求知 |
|
2007-4-2 03:55 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
思路不错,但是硬盘传输速率随文件大小一般变化较大,而且微秒值太小,批处理基本反映不过来,毫秒也勉强
Last edited by zh159 on 2007-4-1 at 03:10 PM ]
The idea is good, but the hard disk transfer rate generally varies greatly with the file size, and the microsecond value is too small, batch processing basically can't reflect it, and milliseconds are barely acceptable
Last edited by zh159 on 2007-4-1 at 03:10 PM ]
|
|
2007-4-2 04:06 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
楼上提得不错。
因为是提出算法。
所以没有给出错误的判断。。。
在我编写的实际批处理例子中。我的方法有不同。。
如果文件的大小小于 86000 * 10 则,动画过程没有延时。。。
2,争对不同的硬盘。我获取硬盘的速率是根据拷贝一个cmd.exe 到 另一个盘的时间做为基准的。。。
3,还有判断,若是同一个盘内的拷贝,也是动画没有延时的。。
这个是实际应用的处理。。
目前还在测试中,就没有在这里献丑了。
提出上面的算法只是把个人的思路提出来和大家一起讨论。。。
实际的代码已经有 32K大小了。。
而且测试也非常成功,只是在copy文件太大的时候,会有点不准。。有1到3秒的误差。
Last edited by flyinspace on 2007-4-1 at 03:27 PM ]
The idea raised by the upstairs is quite good.
Because it's proposing an algorithm.
So there's no judgment of errors...
In the actual batch processing example I wrote, my method is different...
If the size of the file is less than 86000 * 10, then there is no delay in the animation process...
2. For different hard drives, I obtain the speed of the hard drive based on the time taken to copy a cmd.exe to another disk as a reference...
3. Also, there is a judgment that if it's a copy within the same disk, the animation also has no delay.
This is the processing for practical application.
It's still in the testing phase, so I haven't shown it here.
The above algorithm is just to put forward my personal thoughts and discuss with everyone...
The actual code is already 32K in size...
And the testing is also very successful, but when copying very large files, it's a bit inaccurate, with an error of 1 to 3 seconds.
Last edited by flyinspace on 2007-4-1 at 03:27 PM ]
|

知,不觉多。不知,乃求知 |
|
2007-4-2 04:09 |
|
|
huzixuan
高级用户
   
积分 537
发帖 219
注册 2006-10-31 来自 芜湖
状态 离线
|
|
2007-4-2 07:01 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
那里不懂呢??
Where is there any confusion?
|

知,不觉多。不知,乃求知 |
|
2007-4-2 09:34 |
|
|
uiopuiop
中级用户
  
积分 400
发帖 211
注册 2007-9-30
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
运行命令行X(比如COPY 一个大文件)但它要等运行完后才能执行其他代码,有没有办法让它和进度条同时执行和显示?
Running a command line X (such as COPY a large file) but it has to wait until it finishes to execute other code. Is there a way to make it execute and display with a progress bar at the same time?
|
|
2007-10-2 12:39 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
copy /z
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2007-10-2 12:48 |
|
|
jaceyxp
初级用户
 
积分 21
发帖 10
注册 2007-3-30
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
我要运行:
xcopy c:\abc\*.* /s d:\aaa /y
这个命令加在那里??
Where should I add the command:
xcopy c:\abc\*.* /s d:\aaa /y
|
|
2009-1-12 15:02 |
|