Progress Indicator

B

Barney

Each employee's computer has a folder, let's call it
MyFiles, that I backup to the network using a small script.

Is there some way to script a progress indicator -
preferrably one that represents progress expressed as the
percentage of files copied or bytes copied?
 
M

Matthias Tacke

Barney said:
Each employee's computer has a folder, let's call it
MyFiles, that I backup to the network using a small script.

Is there some way to script a progress indicator -
preferrably one that represents progress expressed as the
percentage of files copied or bytes copied?
on 25.10.2003 the same question arose in alt.msdos.batch
Message-ID: <[email protected]>

There was a solution in gawk and a link
http://groups.google.com/groups?&[email protected]

hth
Matthias
 
M

Matthias Tacke

Barney said:
Each employee's computer has a folder, let's call it
MyFiles, that I backup to the network using a small script.

Is there some way to script a progress indicator -
preferrably one that represents progress expressed as the
percentage of files copied or bytes copied?
Another one comes to my mind, wbat from Horst Schaeffer has a nice
area fill function. Since arithmetics is possible, should be easy to
accomplish a funtion called with percentage to show.

otoh its difficult to have a reliable percentage when file sizes differ
extremly.

hth
Matthias
 
P

Phil Robyn

Barney said:
Each employee's computer has a folder, let's call it
MyFiles, that I backup to the network using a small script.

Is there some way to script a progress indicator -
preferrably one that represents progress expressed as the
percentage of files copied or bytes copied?

Try this:

=====begin c:\CMD\TEST\progress.cmd ====================
01. @echo off
02. if "%OS%"=="Windows_NT" goto :begin
03. echo %0 requires Windows NT
04. goto :EOF
05. :begin
06. set bigbar=??????????????????????????????????????????????????
07. :: bigbar is 50 <alt-178> characters
08. ::
09. :: let's say we want to do the equivalent of
10. ::
11. :: 'copy "c:\Program Files\Netscape\Users\Ralph\Cache\*.*" d:\junkdir'
12. ::
13. :: In order to be able to show 'progress', we must do this
14. :: action in a quantifiable way, i.e., on a file-by-file
15. :: basis, rather than in a single command.
16. ::
17. :: First, get a list of the files to be acted upon:
18. ::
19. dir /b "c:\Program Files\Netscape\Users\probyn\Cache\*.*" > %temp%\workdir.$$$
20. ::
21. :: Next, find out how many files there are:
22. ::
23. for /f "tokens=1-3 delims= " %%a in (
24. 'find /v /c "colorless green ideas" %temp%\workdir.$$$') do set num_of_files=%%c
25.
26. set files_copied=0
27. set /a x = num_of_files*10
28.
29. :: in order to make the CLS 'less objectionable' (if that's
30. :: possible), we shrink the window:
31. mode con lines=10 cols=59
32.
33. for /f "tokens=1 delims= " %%a in (%temp%\workdir.$$$) do call :copy_a_file %%a
34. echo Press any key to FINISH
35. pause > nul
36.
37. :: put YOUR favorite window setting here to restore
38. mode con lines=10000 cols=100
39. goto :EOF
40.
41. :copy_a_file
42.
43. set filename=%1
44. set /a files_copied+=1
45. set y=%files_copied%000
46. set /a pct_done = y/x
47. set blength=%pct_done%
48. if 10 LSS %pct_done% set /a blength/=2
49. call set progress=%%bigbar:~0,%blength%%
50. cls
51. echo C O P Y I N G F I L E %filename%
52. echo.
53. echo.
54. echo %pct_done% percent complete
55. echo __________________________________________________
56. echo %progress%
57. echo --------------------------------------------------
58. copy "c:\Program Files\Netscape\Users\probyn\Cache\%filename%" d:\junkdir > nul
59. goto :EOF
=====end c:\CMD\TEST\progress.cmd ====================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top