[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
显示1到100.
  1. @echo off
  2. setlocal enableDelayedExpansion
  3. set str=
  4. for /l %%i in (1 1 100) do (
  5. set tempstr=%%i
  6. set "str=!str! !tempstr!"
  7. )
  8. echo %str%
  9. endlocal
  10. pause
复制代码

TOP

1,3,5...99
  1. @echo off
  2. setlocal enableDelayedExpansion
  3. set str=
  4. for /l %%i in (1 2 99) do (
  5. set tempstr=%%i
  6. set "str=!str! !tempstr!"
  7. )
  8. echo %str%
  9. endlocal
  10. pause
复制代码

TOP

bbs bathome.net
  1. @echo off
  2. for /f "tokens=1,2,3 delims=. " %%a in ("bbs bathome.net") do (
  3. echo %%a
  4. echo %%b
  5. echo %%c
  6. )
  7. endlocal
  8. pause
复制代码

TOP

2 5 8
  1. @echo off
  2. type test.txt
  3. echo.
  4. for /f "tokens=2 delims= " %%a in (test.txt) do (
  5. echo %%a
  6. )
  7. endlocal
  8. pause
复制代码

TOP

第二套b1
  1. @echo off
  2. set poem="床前明月光   疑是地上霜   举头望明月   低头思故乡"
  3. for /f "tokens=1,2,3,4" %%a in ("床前明月光   疑是地上霜   举头望明月   低头思故乡") do (
  4. echo %%a
  5. echo %%b
  6. echo %%c
  7. echo %%d
  8. )
  9. pause
复制代码

TOP

第二套 b2
  1. @echo off
  2. for /r c:/ %%i in (*myplayer*) do (
  3. echo %%~pi
  4. echo %%~ni
  5. echo %%~xi
  6. )
  7. pause
复制代码

TOP

第三题
@echo off
set var=bbs bathome.net
echo %var%
for /f "tokens=1,2" %%a in ("%var%") do (echo %%a&set aab=%%b)
for /f "delims=. tokens=1,2" %%a in ("%aab%") do (echo %%a&echo %%b)
pause >nul

TOP

@echo off
set var="bbs bathome.net"
set var=%var:.= %
set var=%var:"=%
for %%i in (%var%) do echo %%i
pause>nul

TOP

@echo off
for /l %%i in (1 2 100) do @echo %%i
pause>nul

@echo off
set "var=bbs bathome.net"
set var=%var:.= %
for %%i in (%var%) do @echo %%i
pause

@echo off
for /f "delims=" %%i in (test.txt) do @echo %%i
pause

@echo off
for /f "tokens=2" %%i in (test.txt) do @echo %%i
pause

@echo off
set "var=床前明月光   疑是地上霜   举头望明月   低头思故乡"
for %%i in(%var%) do @echo %%i
pause

@echo off
for /f %%i in ('dir /s /b') do (
        if "%%~xni" equ "*mplayer*" echo %%~di & echo %%~ni & echo %%~xi
)
pause>nul

@echo off
for /l %%i in (100 -2 0) do (
        set /a num+=%%i
)
echo %num%

@echo off
for /f "delims=:" %%i in ('ipconfig ^| find "ip address"') do @echo %%j
pause>nul

TOP

返回列表