[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @echo off
  2. for /f "tokens=1 delims=. " %%a in ("bbs bathome.net") do echo %%a
  3. for /f "tokens=2 delims=. " %%b in ("bbs bathome.net") do echo %%b
  4. for /f "tokens=3 delims=. " %%c in ("bbs bathome.net") do echo %%c
  5. pause>nul
复制代码

TOP

第四个问题的

  1. @echo off
  2. color a
  3. for /f "delims=." %%i in (1.txt) do echo %%i
  4. echo _______________________________________
  5. for /f "tokens=2" %%i in (1.txt) do echo %%i
  6. pause
复制代码

TOP

五個題目按順序依次執行
  1. @echo off
  2. for /l %%a in (1,1,100) do echo %%a
  3. pause>nul
  4. for /l %%a in (1,2,99) do echo %%a
  5. pause>nul
  6. set str="bbs bathome.net"
  7. for /f "tokens=1 delims==. " %%a in (%str%) do echo %%a
  8. for /f "tokens=2 delims==. " %%a in (%str%) do echo %%a
  9. for /f "tokens=3 delims==. " %%a in (%str%) do echo %%a
  10. pause>nul
  11. for /f "tokens=1-3 delims==" %%a in (test.txt) do echo %%a
  12. pause>nul
  13. for /f "tokens=2 delims== " %%a in (test.txt) do echo %%a
  14. >nul
  15. @echo on
复制代码

TOP

第四题
  1. @ echo off
  2. for /f "tokens=*" %%i in (f:\test.txt) do echo %%i
  3. for /f "tokens=2" %%i in (f:\test.txt) do echo %%i
  4. pause
复制代码

TOP

1.
  1.   for /l %%i in (1.1.100) echo %%i
  2.   
复制代码
2.
  1.   for /l %%i in (1.2.99) echo %%i
  2.   
复制代码
3.
  1.   @ echo off
  2.   set "str=bbs bathome.net"
  3.   echo %str%
  4.   for %%i in (%str%) do echo %%i
  5.   
复制代码

TOP

  1.                 for  /l %i% in (1.1.100) do echo %i%
  2.                           for  /l %i% in (1.2.99) do echo %i%
  3.                
复制代码

TOP

第三题也可以是这样子

  1. @echo off
  2. set xxx=bbs buthome.net
  3. for /f "tokens=1-3 delims=. " %%i in ("%xxx%") do set s1=%%i && set s2=%%j && set s3=%%k
  4. echo %s1%
  5. echo %s2%
  6. echo %s3%
  7. pause>nul
复制代码

TOP

第四题再发,刚没注意路径

  1. @echo off
  2. cls
  3. for /f "tokens=1-3" %%i in (f:\test.txt) do echo %%i %%j  %%k
  4. for /f "tokens=2"  %%i in (f:\test.txt) do echo %%i
  5. pause
复制代码

TOP

第四题

  1. @echo off
  2. cls
  3. for /f "tokens=1-3" %%i in (test.txt) do echo %%i %%j  %%k
  4. for /f "tokens=2"  %%i in (test.txt) do echo %%i
  5. pause
复制代码

TOP

第三题

  1. @echo off
  2. set yyy=bbs bathome.net
  3. echo %yyy%
  4. for /f "tokens=1" %%i in ("%yyy%") do echo %%i
  5. (for /f "tokens=1 delims=." %%i in ("%yyy%") do echo %%i) >1.txt
  6. for /f "tokens=2" %%i in (1.txt) do echo %%i
  7. for /f "delims=. tokens=2" %%i in ("%yyy%") do echo %%i
  8. pause
复制代码

TOP

我又来了,好想学下东西阿丶

TOP

问题三

方法1
  1. @echo off
  2. for /f "tokens=1-3 delims=. " %%i in ("bbs bathhome.net") do (
  3. echo %%i
  4. echo %%j
  5. echo %%k
  6. )
  7. pause>nul
复制代码
方法2
  1. @echo off
  2. for /f "tokens=1-3 delims=. " %%i in ("bbs bathhome.net") do echo %%i ^
  3. %%j ^
  4. %%k
  5. pause>nul
复制代码

TOP

第一题

  1. @echo off
  2. for /l %%i in (1,1,100) do echo %%i
  3. pause>nul
复制代码
若想在同一行显示
  1. @echo off
  2. for /l %%i in (1,1,100) do echo %%i
  3. pause>nul
复制代码

TOP

同理间隔好可以是, _ 等等。只要用delims重新定义下即可
  1. @echo off
  2. for /f "tokens=1-3 delims=._" %%i  in ("bbs_bathome.net") do (echo %%i &echo %%j &echo %%k)
  3. pause>nul
复制代码

TOP

原帖由 tianya520feng 于 2010-2-1 10:20 发表
我看了前三十贴,第三题的回复都是错的,正确结果如下:

@echo off
for /f "tokens=1-3 delims=. " %%i  in ("bbs bathome.net") do (echo %%i &echo %%j &echo %%k)
pause>nul


这个不错,学习下

TOP

返回列表