Board logo

标题: 这两个枚举批处理有什么不一样 [打印本页]

作者: mqi     时间: 2006-12-20 22:51    标题: 这两个枚举批处理有什么不一样

@echo off
@mode con:cols=80 lines=8
@title 枚举并适时显示
@color 71
@echo   正在枚举中..........
@for /r %%d in (*.*) do @(
              @echo %%d >>result.txt && @(cls && echo%%d)
      )                             
@title 枚举并适时显示  
@start result.txt  
@echo.  
@echo   OK,完成 正在退出..........
@dir %windir% /a /s>nul
exit

下面这个是我改的
@echo off
@mode con:cols=80 lines=8
@title 枚举并适时显示
@color 71
@echo   正在枚举中..........
@for /r %%d in (*.*) do @(
              @echo %%d >>result.txt  
      )                             
@title 枚举并适时显示  
@start result.txt  
@echo.  
@echo   OK,完成 正在退出..........
exit

另外怎样才能使生成的result.txt 中的文件不显路径
作者: hxuan999     时间: 2006-12-21 09:58
1,上面的那个就是多了一句 && @(cls && echo%%d) ,这样就会在输出到result.txt文件的同时也在屏幕上显示正在枚举的文件名.
2,想不显示路径可以用%%~nxd,另外最好加一个对result.txt文件做个删除处理.
代码如下:
@echo off
@mode con:cols=80 lines=8
@title 枚举并适时显示
@color 71
@echo   正在枚举中..........
if exist result.txt @del result.txt /f/q
@for /r %%d in (*.*) do @(
              @echo %%~nxd >>result.txt && @(cls && echo%%~nxd)
      )                             
@title 枚举并适时显示  
@start result.txt  
@echo.  
@echo   OK,完成 正在退出..........
@dir %windir% /a /s>nul
exit
[ Last edited by hxuan999 on 2006-12-20 at 10:00 PM ]
作者: lxmxn     时间: 2006-12-21 11:22

  最后一句"dir %windir% /a /s>nul"是延时的作用么?

作者: hxuan999     时间: 2006-12-22 01:44
是的,这样就可以在执行EXIT前看到 OK,完成 正在退出.......... 而不是一闪而过了.
作者: mqi     时间: 2006-12-22 02:29
谢谢hxuan999老兄了
作者: redtek     时间: 2006-12-22 02:38
hxuan999兄 “@dir %windir% /a /s>nul” 这句用得又有创意又好玩~:)
欣赏~~
作者: hxuan999     时间: 2006-12-22 23:05
哦,那是楼主给的程序中就有的.呵呵
作者: lxmxn     时间: 2006-12-22 23:18

  如果这样,那延迟的方法不是很多了?