![]() |
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-09-25 10:11 |
47,813 topics / 349,918 posts / today 0 new / 48,274 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] Extract characters with similar formats in the file [a bit difficult, not seen in the forum] |
| Printable Version 3,082 / 23 |
| Floor16 baikaifang | Posted 2007-06-04 22:37 |
| 初级用户 Posts 32 Credits 68 | |
Originally posted by lxmxn at 2007-6-4 16:38: Hello Moderator lxmxn, it's my fault. Don't blame me, okay? Saying "sorry" here to you and also thanking you for your support Friend terse, I used the batch processing you improved for Moderator lxmxn above @echo off for /f "tokens=1* delims=:" %%i in ('findstr /risc:"PCI\\\VEN_....&" *.inf') do ( echo %%j=%%~fdpi >>123.txt ) pause The content extracted is as follows %DEVICE_DESCRIPTION_9K% = Install, PCI\VEN_13C1&DEV_1002&SUBSYS_100213C1=C:\M\3\1\O\oemsetup.inf %DEVICE_DESCRIPTION_9X% = Install, PCI\VEN_13C1&DEV_1003&SUBSYS_100313C1=C:\M\3\1\O\oemsetup.inf %aec6897.DeviceDesc% = aec689x_Inst, PCI\VEN_1191&DEV_000B&SUBSYS_1191000B=C:\M\A\6\aec6897.inf %aec6898.DeviceDesc% = aec689x_Inst, PCI\VEN_1191&DEV_000B&SUBSYS_11916898=C:\M\A\6\aec6897.inf %PCI\VEN_9005&DEV_00C0&SUBSYS_F6209005.DeviceDesc% = adpu160m_Inst,PCI\VEN_9005&DEV_00C0&SUBSYS_F6209005=C:\M\AD\5\ADPU160M.INF %PCI\VEN_9005&DEV_00C0&SUBSYS_F6200E11.DeviceDesc% = adpu160m_Inst,PCI\VEN_9005&DEV_00C0&SUBSYS_F6200E11=C:\M\AD\5\ADPU160M.INF Can you improve it again to only output the content in the red part! Really thank you [ Last edited by baikaifang on 2007-6-4 at 10:50 PM ] |
|
| Floor17 baikaifang | Posted 2007-06-04 23:04 |
| 初级用户 Posts 32 Credits 68 | |
Originally posted by lxmxn at 2007-6-3 15:49: Moderator, I tried it. Two "\" and three "\" have the same output content on my side. |
|
| Floor18 terse | Posted 2007-06-04 23:12 |
| 银牌会员 Posts 946 Credits 2,404 | |
|
The problem is that you don't have it in every line. Some have it, and some still don't, right? If every line were like this, then it would be okay.
|
|
| Floor19 baikaifang | Posted 2007-06-04 23:16 |
| 初级用户 Posts 32 Credits 68 | |
|
Yeah, the extracted content is really messy. There are a lot of unnecessary things output, and there are also many duplicates. It seems really difficult to handle.
|
|
| Floor20 terse | Posted 2007-06-05 00:22 |
| 银牌会员 Posts 946 Credits 2,404 | |
|
Modify the moderator's version again:
@echo off&setlocal enabledelayedexpansion for /f "delims=: tokens=1*" %%i in ('findstr /ris "PCI\\\VEN_....&" *.inf') do ( set "m=%%j" set n=%%~fdpxi set "m=!m:*,=!" echo !m!=!n! >>test.txt ) pause |
|
| Floor21 lxmxn | Posted 2007-06-05 00:39 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Try this, which requires the external command grep.
Grep download address: http://zhenlove.com.cn/cndos/fileup/files/grep.rar |
|
| Floor22 baikaifang | Posted 2007-06-05 20:57 |
| 初级用户 Posts 32 Credits 68 | |
Originally posted by terse at 2007-6-5 00:22: It is a bit better than the previous effect, but there are still many unnecessary ones. For example: PCI\VEN_9004&DEV_7815.DeviceDesc="Adaptec Memory Controller / XOR Engine" =C:\M\AD\8\oemsetup.inf SupportedSubsystemIDs,%PCI\VEN_1095&DEV_3512.DeviceDesc%,0x00010001, 0x35121095=C:\M\AD\9\ASH1205.inf %Win98SupportedControllersSubKey%,%PCI\VEN_1095&DEV_3512.DeviceDesc%,0x00010001, 0x35121095=C:\M\AD\9\ASH1205.inf PCI\VEN_8086&DEV_24DF.DeviceDesc = "Adaptec Embedded Serial ATA HostRAID"=C:\M\AD\A\AARICH.INF Hard work, great master. The following version by lxmxn is basically okay. There are some duplicates. But it can be deleted manually. Originally posted by lxmxn at 2007-6-5 00:39: |
|
| Floor23 baikaifang | Posted 2007-06-05 21:14 |
| 初级用户 Posts 32 Credits 68 | |
|
If the moderator modifies the code and handles the three formats respectively, then all three formats can be extracted, and finally the output files can be combined.
By the way, what is the specific meaning of the following sentence? I need to understand it so that I can modify it myself. Extract the content in different formats. for /f "tokens=1* delims=:" %%b in ('grep -o "PCI\\VEN_[[:alnum:]]\{4\}&DEV_[[:alnum:]]\{4\}&SUBSYS_[[:alnum:]]\{8\}" "%%a"') |
|
| Floor24 lxmxn | Posted 2007-06-05 21:52 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Re baikaifang:
What characteristics of the string like "PCI\VEN_13C1&DEV_1002&SUBSYS_100213C1" that you want to extract can be "utilized"? If there are some characteristics that distinguish it from other strings, I think things will become easier. As for this grep command, it finds matching characters and only outputs the matching characters. If you want to study its usage in depth, you can search for relevant materials on the Internet to have a look. |
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |