1、批处理运行窗口显示1~100 这100 个数字- for /l %%i in (1,1,100) do echo %%i
复制代码 2、批处理运行窗口显示 1、3、5.....99这50个数字;- for /l %%i in (1,2,100) do echo %%i
复制代码 3、将 bbs bathome.net (在同一行)分成三行显示在批处理运行窗口- @echo off
- set txt=bbs bathome.net
- for /f "tokens=1,2,3" %%i in ("%txt%") do set s1=%%i && set s2=%%j && set s3=%%k
- echo %s1%
- echo %s2%
- echo %s3%
- pause>nul
复制代码 4、
①将f:\test.txt内容全部显示在批处理窗口复制代码 或者- @echo off
- for /f "tokens=1,2,3" %%i in (test.txt) do echo %%i %%j %%k
- pause>nul
复制代码 ②只显示 2 5 8显示在批处理窗口(分三行显示,每字一行)- @echo off
- setlocal EnableDelayedExpansion
- set index=0
- for /f "tokens=2" %%i in (test.txt) do (
- set /a index+=1
- set str!index!=%%i
- )
- echo %str1%
- echo %str2%
- echo %str3%
- pause>nul
复制代码
|