中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 00:36
47,811 topics / 349,897 posts / today 2 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » Question about the for command
Printable Version  808 / 2
Floor1 SamuelFish Posted 2008-07-26 10:17
初级用户 Posts 30 Credits 61
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.
Floor2 alwaysrun Posted 2008-09-27 12:00
新手上路 Posts 5 Credits 9
Split each line of the txt file into multiple tokens by spaces, and output the 12th token.
Floor3 ZJHJ Posted 2008-09-28 22:10
高级用户 Posts 374 Credits 609
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
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023