标题: [文本处理] 批处理进度条显示 [打印本页]
作者: zhudonhua 时间: 2009-1-21 13:35 标题: 批处理进度条显示
问题背景:
从sp.log依次中读取一条记录,然后去连接数据库,但是每次连接可能要花费20S的时间,考虑到可能会有上百次操作,因而需要有个进度提示信息。。
下面是我写的代码,帮忙看看哪里有问题???
/*读取sp.log中总共有多少行记录*/- set /a m=1
- for /F "usebackq skip=2 tokens=1,2,3" %%i in ("%log%\sp.log") do (
- set /a m += 1
- )
-
- set count=1
- for /F "usebackq skip=2" %%i in ("%log%\sp.log") do (
- echo Backing up Store Procedure %%i >> "%log%\backup_all_sp_%db%_%srvname%_%year%%mon%%day%_%hour%%min%%ss%.log"
- sqlcmd -S%srvname% -d%db% -U%user% -P%password% -Q "select text from syscomments where id=object_id(%%i)" -o "%bak%\%srvname%_%db%_%%i_%year%%mon%%day%_%hour%%min%%ss%.PRC"
- echo ... Finished: %count%/%m% ...
- set /a count += 1
- )
复制代码
问题:
显示出来的不是预想中的结果
--------------------------------------
显示效果
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
作者: yslyxqysl 时间: 2009-1-21 13:52
- @echo off
- setlocal ENABLEDELAYEDEXPANSION
- set /a m=1
- for /F "usebackq skip=2 tokens=1,2,3" %%i in ("%log%\sp.log") do (
- set /a m += 1
- )
-
- set count=1
- for /F "usebackq skip=2" %%i in ("%log%\sp.log") do (
- echo Backing up Store Procedure %%i >> "%log%\backup_all_sp_%db%_%srvname%_%year%%mon%%day%_%hour%%min%%ss%.log"
- sqlcmd -S%srvname% -d%db% -U%user% -P%password% -Q "select text from syscomments where id=object_id(%%i)" -o "%bak%\%srvname%_%db%_%%i_%year%%mon%%day%_%hour%%min%%ss%.PRC"
- echo ... Finished: !count!/%m% ...
- set /a count += 1
- )
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |