Post by bsnHi group...
I have made a little batch program for upload to internet...
I want a progress bar going, while uploading...
Is there a solution in DOS ???
Kindly
Bjarne
Depends. Here's an example:
=====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. setlocal
07. :: save the current console lines and columns values:
08. for /f "tokens=2 delims=: " %%a in (
09. 'mode ^| find "Lines:"'
10. ) do set lines=%%a
11. for /f "tokens=2 delims=: " %%a in (
12. 'mode ^| find "Columns:"'
13. ) do set columns=%%a
14. set bigbar=²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
15. :: bigbar is 50 <alt-178> characters
16. ::
17. :: let's say we want to do the equivalent of
18. ::
19. :: 'copy "c:\temp\*.txt" c:\junkdir\txt'
20. ::
21. :: In order to be able to show 'progress', we must do this
22. :: action in a quantifiable way, i.e., on a file-by-file
23. :: basis, rather than in a single command.
24. ::
25. :: First, get a list of the files to be acted upon:
26. ::
27. dir /b "c:\temp\*.txt" > %temp%\workdir.$$$
28. ::
29. :: Next, find out how many files there are:
30. ::
31. for /f "tokens=1-3 delims= " %%a in (
32. 'find /v /c "" %temp%\workdir.$$$') do set num_of_files=%%c
33.
34. set files_copied=0
35. set /a x = num_of_files*10
36.
37. :: in order to make the CLS 'less objectionable' (if that's
38. :: possible), we shrink the window:
39. mode con lines=12 cols=99
40.
41. for /f "tokens=*" %%a in (%temp%\workdir.$$$) do call :copy_a_file "%%a"
42. echo Press any key to FINISH
43. pause > nul
44. :: restore the previous console lines and columns settings:
45. mode con lines=%lines% cols=%columns%
46. goto :EOF
47.
48. :copy_a_file
49.
50. set filename=%~1
51. set /a files_copied+=1
52. set y=%files_copied%000
53. set /a pct_done = y/x
54. set blength=%pct_done%
55. if 10 LSS %pct_done% set /a blength/=2
56. call set progress=%%bigbar:~0,%blength%%%
57. cls
58. echo/ __________________________________________________
59. echo/ %progress%
60. echo/ --------------------------------------------------
61. echo/ Copying %filename%
62. echo/
63. echo/ total: %num_of_files% copied: %files_copied%
64. echo/
65. echo/ %pct_done% percent complete
66. echo/
67. copy "c:\temp\%filename%" d:\junkdir\txt\ > nul
68. goto :EOF
=====end C:\cmd\test\Progress.cmd ====================
--
Phil Robyn
Univ. of California, Berkeley
u n z i p m y a d d r e s s t o s e n d e - m a i l