China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 23:37
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about the for command View 806 Replies 2
Original Poster Posted 2008-07-26 10:17 ·  中国 广东 东莞 电信
初级用户
Credits 61
Posts 30
Joined 2008-01-16 05:45
18-year member
UID 108734
Gender Male
Status Offline
Today I looked into a batch file for binding an IP. The file is as follows:
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt
if exist phyaddr.txt del phyaddr.txt
find "Physical Address" ipconfig.txt >phyaddr.txt
for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M
phyaddr.txt is shown as:

---------- IPCONFIG.TXT
Physical Address. . . . . . . . . : 00-60-B3-6E-EB-69

What I want to know is, what does tokens=12 mean???
Also, if I want to export the value of the variable MAC to 1.txt, how should I do it?
I've thought about it for a long time, and I hope an expert can give me some pointers. Thanks.
Floor 2 Posted 2008-09-27 12:00 ·  中国 上海 闵行区 电信
新手上路
Credits 9
Posts 5
Joined 2008-09-09 10:56
17-year member
UID 125191
Gender Male
Status Offline
Split each line of the txt file into multiple tokens by spaces, and output the 12th token.
Floor 3 Posted 2008-09-28 22:10 ·  中国 四川 泸州 联通
高级用户
★★★
Credits 609
Posts 374
Joined 2006-08-02 22:38
20-year member
UID 59720
Status Offline
Use ipconfig /all to get the network configuration, then use find to look for the Physical Address item in the acquired data, which is the NIC
address code. In Physical Address. . . . . . . . . : 00-60-B3-6E-EB-69, there are many ways to get
the 00-60-B3-6E-EB-69 part. You can use spaces as delimiters, or you can use : as the delimiter. Just write
the obtained NIC address code 00-60-B3-6E-EB-69 into 1.txt.

ipconfig /all >bd.txt
find "Physical Address" bd.txt >wk.txt
for /f "tokens=2 delims=:" %%M in (wk.txt) do echo %%M>1.txt
Forum Jump: