![]() |
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 14:58 |
47,811 topics / 349,897 posts / today 0 new / 48,255 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] Extract characters with similar formats in the file [a bit difficult, not seen in the forum] |
| Printable Version 2,698 / 23 |
| Floor1 baikaifang | Posted 2007-06-02 23:23 |
| 初级用户 Posts 32 Credits 68 | |
|
Extract characters with similar formats from files, and these files are not in the same directory
First, let's explain: The files from which you need to extract content are distributed in different folders. And the levels of the folders where they are located are also different. At the same time, you also need to append the path of the file to the output content. Here is the folder structure: C:\SRS-DRV ├─3 │ ├─1 │ │ └─O │ ├─2 │ └─3 ├─A │ ├─1 │ ├─2 │ ├─3 │ ├─4 │ ├─5 │ ├─6 │ ├─7 │ └─8 ├─AD │ ├─1 │ ├─2 │ ├─3 │ ├─4 │ ├─5 │ ├─6 │ │ └─C │ ├─7 │ ├─8 │ ├─9 │ └─A ├─AM ├─AR ├─AT ├─AU │ ├─1 │ ├─2 │ └─3 ├─C ├─D │ ├─1 │ ├─2 │ └─3 ├─E ├─H │ ├─1 │ │ └─R │ ├─2 │ ├─3 │ ├─4 │ ├─5 │ ├─6 │ │ └─2k3 │ ├─7 │ └─8 ├─I │ ├─1 │ ├─2 │ ├─3 │ ├─4 │ ├─5 │ └─6 ├─IN │ ├─1 │ │ └─O │ └─2 │ └─winnt │ └─x86 ├─IT ├─J │ ├─1 │ └─2 ├─L │ ├─1 │ ├─2 │ ├─3 │ ├─4 │ └─5 ├─M │ └─O ├─N │ ├─123 │ ├─4 │ │ ├─I │ │ └─R │ ├─4INTEL │ │ ├─I │ │ └─R │ ├─590SLI │ │ ├─I │ │ └─R │ └─TM ├─P │ ├─1 │ ├─2 │ │ └─A │ ├─3 │ ├─4 │ ├─5 │ ├─6 │ ├─7 │ ├─8 │ └─9 ├─Q │ ├─1 │ ├─2 │ ├─3 │ └─4 ├─S │ ├─1 │ ├─2 │ ├─3 │ ├─4 │ ├─5 │ │ └─A │ ├─6 │ ├─7 │ │ └─A │ ├─8 │ ├─9 │ ├─A │ ├─B │ └─C ├─SI │ ├─1 │ ├─2 │ └─3 ├─V │ ├─1 │ ├─2 │ └─3 └─VM Basically, there is an INF file with the extension .INF under each folder. If there is content similar to the red part below in that INF file, output it to 1.TXT (if there are multiple lines like this in a file, all should be output), and append the path of the file to the output content. (If a file has multiple matching places, output all of them and add the path of the file at the end of each line, for example, the blue parts below.) For example: PCI\VEN_13C1&DEV_1000=C:\SRS-DRV\3\3\oemsetup3.inf PCI\VEN_1191&DEV_0002&SUBSYS_00021191=C:\SRS-DRV\A\1\Aec6210.inf PCI\VEN_1191&DEV_0006&SUBSYS_00061191&REV_01=C:\SRS-DRV\A\2\Aec6260.inf PCI\VEN_1022&DEV_7409=C:\SRS-DRV\AM\AMDEIDE.inf PCI\VEN_1022&DEV_7411=C:\SRS-DRV\AM\AMDEIDE.inf PCI\VEN_1022&DEV_7441=C:\SRS-DRV\AM\AMDEIDE.inf PCI\VEN_1022&DEV_7469=C:\SRS-DRV\AM\AMDEIDE.inf The part in front is extracted from the file, and the part after the equal sign is the path of the file from which the content is extracted. The content to be extracted has several similar characteristics: 1. All start with PCI\VEN. (Note: Here it means that the content I want to extract starts with PCI\VEN, not that the line where this content is located starts with PCI\VEN. Only the content between PCI\VEN and containing one "\" is needed, and content with more than one "\" is not needed.) 2. There are two separators "_" and "&" in the content, and the number of separators is different. The files on the page of the following link are used to make the 1.TXT file, and the directory tree structure above is that of the link file. http://driverpacks.net/DriverPacks/download.php?pag=m The files used are downloadable on the above link page. I have too low a level and seem unable to upload attachments for now! Thank you all here in advance, great experts. The original intention of hoping to implement the above function with a batch script: The original post is quoted from the Dragon Empire Forum, posted by eyeshare on 07-5-3 11:07 Original post address of the quoted article http://bbs.mscode.cc/thread-51438-1-2.html [ Last edited by baikaifang on 2007-6-3 at 08:04 PM ] |
|
| Floor2 namejm | Posted 2007-06-03 15:09 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
It has been left for so long without anyone paying attention, so I'll give it a try.
First, ask the original poster: "The previous part was extracted from a file". What exactly does this file look like? You'd better send it as an attachment. |
|
| Floor3 electronixtar | Posted 2007-06-03 15:14 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
Don't use difficulty to scare people
findstr /r /i "PCI\\VEN.*&DEV_" |
|
| Floor4 wudixin96 | Posted 2007-06-03 15:20 |
| 银牌会员 Posts 931 Credits 1,928 | |
|
I have tried. The content in the inf file under his folder is extremely irregular.
There are spaces and so on from time to time before PCI\\VEN.*&DEV. It needs to be filtered several times to extract it. Hope that seniors like namejm, electronixtar can come up with a more efficient one. Looking forward... |
|
| Floor5 lxmxn | Posted 2007-06-03 15:39 |
| 版主 Posts 4,938 Credits 11,386 | |
|
I don't understand why the file path after the = sign in the 1.txt file is different from the tree structure of the folder above. Sweat.
|
|
| Floor6 wudixin96 | Posted 2007-06-03 15:44 |
| 银牌会员 Posts 931 Credits 1,928 | |
|
PCI\\\VEN why are there three \. Isn't it two?
And the structure in the inf file is like this %DEVICE_DESCRIPTION% = Install, PCI\VEN_13C1&DEV_1002&SUBSYS_100213C1 It's not starting with PCI\VEN. Sorry. Thought too much. Excessive. [ Last edited by wudixin96 on 2007-6-3 at 04:12 PM ] |
|
| Floor7 lxmxn | Posted 2007-06-03 15:49 |
| 版主 Posts 4,938 Credits 11,386 | |
Originally posted by wudixin96 at 2007-6-3 15:44: The first \ cancels the escape of the second \, getting a "real" \, and then this \ cancels the special meaning of the third \. (This is how I understand it) As for not starting with PCI\VEN, I am looking at the owner's explanation written like this:
|
|
| Floor8 baikaifang | Posted 2007-06-03 19:07 |
| 初级用户 Posts 32 Credits 68 | |
Originally posted by namejm at 2007-6-3 15:09: The file used is the one downloaded from the link at the bottom of the first floor. |
|
| Floor9 baikaifang | Posted 2007-06-03 19:10 |
| 初级用户 Posts 32 Credits 68 | |
Originally posted by electronixtar at 2007-6-3 15:14: Great expert electronixtar, I only know some simple batch processing. I wrote the post title like that just to hope to get the help from all great experts. Please don't take it to heart! [ Last edited by baikaifang on 2007-6-3 at 07:48 PM ] |
|
| Floor10 baikaifang | Posted 2007-06-03 19:23 |
| 初级用户 Posts 32 Credits 68 | |
Originally posted by wudixin96 at 2007-6-3 15:44: I'm sorry, my expression was a bit vague. What I meant by starting with PCI\VEN is that all the content I need to extract starts with PCI\VEN, not that it's in the line starting with PCI\VEN. |
|
| Floor11 baikaifang | Posted 2007-06-03 19:32 |
| 初级用户 Posts 32 Credits 68 | |
Originally posted by lxmxn at 2007-6-3 15:39: |
|
| Floor12 baikaifang | Posted 2007-06-04 16:28 |
| 初级用户 Posts 32 Credits 68 | |
|
Waited all day and no one bumped it, so I'll do it myself
|
|
| Floor13 terse | Posted 2007-06-04 16:34 |
| 银牌会员 Posts 946 Credits 2,404 | |
|
Is the version by moderator lxmxn not already prepared?
|
|
| Floor14 lxmxn | Posted 2007-06-04 16:38 |
| 版主 Posts 4,938 Credits 11,386 | |
Originally posted by baikaifang at 2007-6-4 16:28: Don't blame others for not reading. Your meaning wasn't clear at all, so everyone is too lazy to read. If you can't explain clearly, give an example. Don't say ambiguous things. |
|
| Floor15 terse | Posted 2007-06-04 18:03 |
| 银牌会员 Posts 946 Credits 2,404 | |
|
@echo off
for /f "tokens=1* delims=:" %%i in ('findstr /risc:"PCI\\\VEN_....&" *.inf') do ( echo %%j=%%~fdpi >>123.txt ) pause Is this the multiple paths written by version master lxmxn? |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |