Gregory
If you mean in terms of manual display after each or a number of
commands are processed within the batch, how about
command
cls & echo *
command
cls & echo **
command
cls & echo ***
command
cls & echo ****
or similar.
=====begin c:\cmd\demo\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:\cmd\test\*.*" 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:\cmd\test\*.*" > %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:\cmd\test\%filename%" d:\junkdir > nul
59. goto :EOF
=====end c:\cmd\demo\progress.cmd====================
--
U s e ' R e p l y - T o ' a d d r e s s o r
u n z i p ' F r o m ' t o s e n d m a i l
No need to clear the screen
@echo off&setlocal ENABLEEXTENSIONS
for /l %%a in (1,1,10) do (
echo/|set /p ^=^.
ping 127.0.0.1 -n 2 >nul
)
or
@echo off&setlocal
::Do Some Work
ping 127.0.0.1 -n 2 >nul&call :Progress
::Do Some more Work
ping 127.0.0.1 -n 2 >nul&call :Progress
::Do Some more more Work
ping 127.0.0.1 -n 2 >nul&call :Progress
echo/
goto :EOF
:Progress
echo/|set /p ^=^.
goto :EOF
--
Ritchie
Undo address for mail
^ echo/|set /p ^=^.
Interesting! You've discovered a method of printing text without a new line:
Echo/|Set /p ^=Left &Echo Right
When is the second escape character necessary? In a script?
SET/A can be used in a similar fashion but, obviously, only with numbers:
@Echo off&SetLocal ENABLEEXTENSIONS
For /L %%a in (1,1,10) Do (
Set /a 0
Ping 127.0.0.1 -n 2 >NUL:
)
Frank
When you want to get an idea of who's reading or blindly copying your
posts??? (thats the best reason I can think of anyway).
set /p ^=.<nul
... over the redirect. No particular reason but figured it worth a
mention.
Dean
--
Dean Wells [MVP / Windows platform]
MSEtechnology
dwe...@msetechnology.com
[[ Please respond to the Newsgroup only ]]
"Ritchie" <rit...@commanddoline.co.uk> wrote in message
news:3ddcb6bc$0$1294$cc9e...@news.dial.pipex.com...
^ "Frank" news:01c29151$d3379950$0125250a@mjtfqbuyhrfregky...
^ > When is the second escape character necessary? In a script?
^
^ When you want to get an idea of who's reading or blindly copying your
^ posts???
Blind is right. I blindly assumed that the first escape character was
necessary but it seems that neither is.
Thanks for the trick!
Frank
^ Ritchie <3ddcb6bc$0$1294$cc9e...@news.dial.pipex.com>...
^
^ ^ echo/|set /p ^=^.
^
^ Interesting! You've discovered a method of printing text without a new
line:
^
^ Echo/|Set /p ^=Left &Echo Right
Oddly, that also works in NT4 where SET doesn't have the /P switch.
Echo/|Set /p =Left &Echo/|Set /p =Middle &Echo Right
But it does set errorlevel=1.
Frank
^ Oddly, that also works in NT4 where SET doesn't have the /P switch.
Oops! Maybe not. It turns out that %ComSpec% is used when a command line
consists of multiple commands as above.
In an NT4 console with ComSpec set to a Windows 2000 CMD.EXE:
>VER
Windows NT Version 4.0
>ECHO|VER
Microsoft Windows 2000 [Version 4.00.1381]
>VER>&2|VER
Microsoft Windows 2000 [Version 4.00.1381]
Microsoft Windows 2000 [Version 4.00.1381]
So when I invoke 'Echo/|Set /p =Left &Echo Right' in an NT4 console each of
the three commands are being handed to a Windows 2000 CMD.EXE.
I think Garry is setup to test this properly for NT4.
Frank
I only get the last echo in NT.
D:\>Echo/|Set /p =Left &Echo/|Set /p =Middle &Echo Right
Right
BTW, I use the following to make sure %comspec% is set to the
appropriate copy of Cmd.
@echo off
set ComSpec=d:\bat\xp\cmd.exe
set path=d:\bat\xp;%path%
start "XP Cmd prompt" d:\bat\xp\cmd.exe
It's necessary to set %comspec% PRIOR to starting Cmd, it doesn't get
used by Cmd if it is changed after Cmd has started. Pretty much like
setting Comspec in Config.sys under dos.
Garry
Along these lines, I like using the Title command to display thing
informational things but I don't want to clutter the output.
command
Title *
command
Title **
command
Title ***
command
Title ****
etc.
That's a good trick, however, if your batch file is going to be working for
a while in the background while you perhaps do other things, I would
recommend prefixing whatever is passed to the title command with some token
indicative of progress that can be seen on the toolbar button when the
window is minimized, something like:
command
Title phase 1 *
command
Title phase 2 **
command
Title phase 3***
command
Title phase 4 ****
/Al