[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[其他] [已解决]如何提取TXT中指定的内容?

本帖最后由 yaojogd 于 2011-10-24 20:55 编辑

文件事例内容
"JumboFrameSize"="0"
"LowPowerStateLinkSpeed"="0"
"PollIntervalInus"="0"
"PriorityVLANTag"="0"
"SegOffload"="0"
"WakeUpMagic"="0"
"WakeUpPattern"="0"
"InfPath"="oem6.inf"
"InfSection"="NVENET_XPNPR.NDI"
"InfSectionExt"=".NT"
"ProviderName"="NVIDIA"
"DriverDateData"=hex:00,80,73,8a,69,f3,c8,01
"DriverDate"="8-1-2008"
"DriverVersion"="67.8.9.0"
"MatchingDeviceId"="{1a3e09be-1e45-494b-9174-d7385b45bbf5}\\nvnet_dev0057"
"DriverDesc"="NVIDIA nForce 10/100/1000 Mbps Ethernet "
"NetCfgInstanceId"="{A9F0C927-1EC0-495A-A141-AD1104871D4C}"



只需要提取"NetCfgInstanceId"="{A9F0C927-1EC0-495A-A141-AD1104871D4C}"中的{A9F0C927-1EC0-495A-A141-AD1104871D4C}到txt
1

评分人数

    • CrLf: 感谢给帖子标题标注[已解决]字样PB + 2

  1. @echo off
  2. for /f "tokens=1,2 delims==" %%a in ('findstr "NetCfgInstanceId" a.txt') do echo %%~b
  3. pause
复制代码
1

评分人数

    • CrLf: 乐于助人技术 + 1

TOP

谢谢楼上,额``字数补丁

TOP

回复 7# yaojogd


    更新顶楼!
  1. echo off
  2. for /f "tokens=1*delims==" %%a in ('type "j:\11.txt"^|findstr "NetCfgInstanceId"') do set str=%%~b
  3. echo %str%>j:\2.txt
  4. pause
复制代码
1

评分人数

    • CrLf: 乐于助人技术 + 1
http://www.diecasting86.com

TOP

我用regedit /e j:\11.txt HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001
把内容放在11.txt里,在想把里面"NetCfgInstanceId"后面的{29898C9D-B0A4-4FEF-BDB6-57A562022CEE}输出到另一个文件里,比如2.txt

TOP

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001]
"NewDeviceInstall"=dword:00000000
"NetCfgInstanceId"="{29898C9D-B0A4-4FEF-BDB6-57A562022CEE}"
"*IfType"=dword:00000083
"Characteristics"=dword:00000029
"*MediaType"=dword:0000000c
"*PhysicalMediaType"=dword:00000000
"NetLuidIndex"=dword:00000001
"DeviceInstanceID"="ROOT\\MS_AGILEVPNMINIPORT\\0000"
"InstallTimeStamp"=hex:db,07,07,00,06,00,09,00,0c,00,02,00,27,00,3e,03
"MinWanEndpoints"=dword:00000000
"MaxWanEndpoints"=dword:00000003
"WanEndpoints"=dword:00000002
"ComponentId"="ms_agilevpnminiport"
"InfPath"="netavpna.inf"
"InfSection"="Ndi-Mp-AgileVpn"
"ProviderName"="Microsoft"
"DriverDateData"=hex:00,80,8c,a3,c5,94,c6,01
"DriverDate"="6-21-2006"
"DriverVersion"="6.1.7601.17514"
"MatchingDeviceId"="ms_agilevpnminiport"
"DriverDesc"="WAN Miniport (IKEv2)"

TOP

  1. echo off
  2. for /f "tokens=1*delims==" %%a in ('type "10.txt"^|findstr "NetCfgInstanceId"') do set str=%%~b
  3. echo %str%>new.txt
  4. pause
复制代码
http://www.diecasting86.com

TOP

不是呢`是"NetCfgInstanceId"="{A9F0C927-1EC0-495A-A141-AD1104871D4C}"中的{A9F0C927-1EC0-495A-A141-AD1104871D4C}这段,这短不是固定这些表达,但是长度是一样的
这个是注册表中网卡的代码

TOP

  1. @echo off
  2. for /f "tokens=1*delims==" %%a in (1.txt) do set str=%%~b
  3. echo %str%
  4. pause
复制代码
或者
  1. @echo off
  2. for /f tokens^=3delims^=^" %%a in (1.txt) do set str=%%a
  3. echo %str%
  4. pause
复制代码

TOP

你的意思是只提取最后一行吗?

TOP

返回列表