本帖最后由 aloha20200628 于 2024-8-31 11:42 编辑
回复 1# SeanJuicer
假设源数据某一段落如下:
...
以太网适配器 xxx:
...
... : 172.5...
...
则以下代码会获取 ‘以太网适配器’ 其后的 xxx 字段值
| @echo off &set "go=1" &for /f "tokens=1,2 delims=:" %%a in ( | | 'ipconfig /all^|findstr /il /c:"以太网适配器" /c:": 172.5." ' | | ) do if defined go ( | | if "%%b"=="" (for /f "tokens=1* delims= " %%x in ("%%a") do set "AdapterName=%%y") else set "go=" | | ) | | echo,%AdapterName%&pause&exit/bCOPY |
|