nice batch

来源:互联网 发布:linux内核论坛 编辑:程序博客网 时间:2024/05/20 00:13


1.变量延迟和变量替换
rem this batch is used to eliminate those unnecessary language tag
@echo
 off
setlocal enabledelayedexpansion
for /r %%i in (*.xml) do (
    
set ke=%%i
rem replace the  by /
    set file=!ke:=/!
rem agurments are bracked by "" in case of the backspace in the path
    Xml2Xls.exe "!file!" "!file!"
)
pause
 2.使用命令结果
rem Create directory and copy files
@echo off
for /"tokens=*" %%i in ('dir /ad /b') do (
    
md "%%iAssetsXMLText"
    
copy "%%i*.xml" "%%iAssetsXMLText"
    del 
"%%i*.xml"
)
pause
3.call 在这里起到延迟变量的作用与变量截取.结果12       
  1.   @echo off
  2.   set c=2
  3.   set a=123
  4.   call set b=%%a:~0,%c%%%
  5.   echo %b%
  6.   pause
  7.  
  8.   setlocal enabledelayedexpansion
  9.   set b=!a:~0,%c%!
  10.   echo !b!
  11.   pause

4. ping遍局域网
  1. for /L %i in (1,1,255do @ping -a 192.168.0.%i