Discussion:
Progress bar
(too old to reply)
bsn
2005-03-31 15:46:17 UTC
Permalink
Hi 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
Paul R. Sadowski [MVP]
2005-03-31 20:22:56 UTC
Permalink
Hello, bsn:
On Thu, 31 Mar 2005 17:46:17 +0200: you wrote...

b> Hi group...
b> I have made a little batch program for upload to internet...
b> I want a progress bar going, while uploading...
b> Is there a solution in DOS ???

Well, I wrote a little spinning wheel VBscript a few years ago. (I
originally just threw it together quickly like echo sleep echo for a long
running script and someone from Microsoft cleaned it up in one of the
scripting groups. I'd like to him credit but can't remember his name after
all this time. :( Anyway...)

You could run a batch file from a script calling the spin sub while the
batch is still running. It won't show progress values, it just indicates
that the script is running.

Something like this run with cscript:

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("c:\bin\scripts\test.cmd")

Do While oExec.Status = 0
spin
Loop

sub spin
back=string(4,chr(8))
progress=Array("\","|","/","-")
for each c in progress
wscript.stdout.write "["& c &"]"
wscript.sleep 50
wscript.stdout.write back
next
end sub


Regards, Paul R. Sadowski [MVP].
Bjarne
2005-04-05 20:15:12 UTC
Permalink
Post by Paul R. Sadowski [MVP]
On Thu, 31 Mar 2005 17:46:17 +0200: you wrote...
b> Hi group...
b> I have made a little batch program for upload to internet...
b> I want a progress bar going, while uploading...
b> Is there a solution in DOS ???
Well, I wrote a little spinning wheel VBscript a few years ago. (I
originally just threw it together quickly like echo sleep echo for a long
running script and someone from Microsoft cleaned it up in one of the
scripting groups. I'd like to him credit but can't remember his name after
all this time. :( Anyway...)
Thank you for answer...
I wrote to Phil, maybe i can use his solution...
Bjarne
Phil Robyn
2005-03-31 21:23:05 UTC
Permalink
Post by bsn
Hi 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
Bjarne
2005-04-05 20:12:51 UTC
Permalink
Post by bsn
Hi 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
Hello Phil
Thank you for your answer -
Here is my little script...:

===Start===
echo off
echo "Databasen overføres til Internettet..."
bell
ftp -s:put.txt ftp.hoejbynet.dk
echo "Overførsel af databasen til Internettet er afsluttet..."
pause
===End===

I am not an eagle to DOS
Will you help me incorporate it in your script ???
Sensirely
Bjarne
Herbert Kleebauer
2005-04-05 21:18:17 UTC
Permalink
Post by Bjarne
Post by bsn
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 ???
===Start===
echo off
echo "Databasen overføres til Internettet..."
bell
ftp -s:put.txt ftp.hoejbynet.dk
echo "Overførsel af databasen til Internettet er afsluttet..."
pause
===End===
Insert the ftp command "hash" into put.txt after
the logon command.
Bjarne
2005-04-06 14:31:25 UTC
Permalink
Post by Herbert Kleebauer
Post by Bjarne
Post by bsn
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 ???
===Start===
echo off
echo "Databasen overføres til Internettet..."
bell
ftp -s:put.txt ftp.hoejbynet.dk
echo "Overførsel af databasen til Internettet er afsluttet..."
pause
===End===
Insert the ftp command "hash" into put.txt after
the logon command.
I do not understand - why "hash" into put.txt after
the logon command.- is it a security thing...
Bjarne
Bjarne
2005-04-06 15:02:25 UTC
Permalink
Post by Herbert Kleebauer
Post by Bjarne
Post by bsn
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 ???
===Start===
echo off
echo "Databasen overføres til Internettet..."
bell
ftp -s:put.txt ftp.hoejbynet.dk
echo "Overførsel af databasen til Internettet er afsluttet..."
pause
===End===
Insert the ftp command "hash" into put.txt after
the logon command.
Sorry - i tried inserting hash, it works fine - thank you...
Bjarne

Loading...