China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 04:12
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Extract characters with similar formats in the file [a bit difficult, not seen in the forum] View 2,524 Replies 23
Original Poster Posted 2007-06-02 23:23 ·  中国 湖南 永州 电信
初级用户
Credits 68
Posts 32
Joined 2006-10-20 12:14
19-year member
UID 67277
Status Offline
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
The experience of loading SATA RAID SCSI drivers before encapsulation, which can be used without modification of SRS


I think the most important thing in making a ghost system is the judgment of the power mode and the accurate loading of SRS drivers. Now the judgment of the power mode has a very good solution, and the most main problem is now how to load the SRS drivers before encapsulation and uninstall the redundant drivers during the minimal installation to speed up the system boot speed. In fact, referring to Microsoft's deployment documents can solve it. Now I will talk about my method (I won't say much about other steps before encapsulation, such as changing the power mode, etc.)

1. Collect the required SRS drivers, which can be directly downloaded from the massstorage drivers of DPS.
http://www.driverpacks.net/DriverPacks/download.php?pag=m
2. Extract the drivers to c:\drivers.
3. Edit sysprep.ini and add the following content
InstallFilesPath=C:\sysprep\i386


PCI\VEN_1022&DEV_7469=c:\drivers\m\am\AMDEIDE.inf
PCI\VEN_1002&DEV_4349=c:\drivers\m\at\atiide.inf
PCI\VEN_10B9&DEV_5215=c:\drivers\m\au\1\ALIIDE.INF
PCI\VEN_10B9&DEV_5219=c:\drivers\m\au\1\ALIIDE.INF
PCI\VEN_10B9&DEV_5229=c:\drivers\m\au\1\ALIIDE.INF
PCI\VEN_10B9&DEV_5228=c:\drivers\m\au\2\m5228.INF
PCI\VEN_10B9&DEV_5281=c:\drivers\m\au\2\m5281.inf
PCI\VEN_10B9&DEV_5287=c:\drivers\m\au\3\ulisata.inf
PCI\VEN_10B9&DEV_5288=c:\drivers\m\au\4\ULISATA.INF
PCI\VEN_10B9&DEV_5289=c:\drivers\m\au\5\ULISATA.INF
PCI\VEN_8086&DEV_2652&CC_0104=c:\drivers\m\in\1\iastor.inf
PCI\VEN_8086&DEV_27C3&CC_0104=c:\drivers\m\in\1\iastor.inf
PCI\VEN_8086&DEV_2682&CC_0104=c:\drivers\m\in\1\iastor.inf
PCI\VEN_8086&DEV_27C6&CC_0104=c:\drivers\m\in\1\iastor.inf
PCI\VEN_8086&DEV_2822&CC_0104=c:\drivers\m\in\1\iastor.inf
PCI\VEN_8086&DEV_2652&CC_0106=c:\drivers\m\in\1\iaahci.inf
PCI\VEN_8086&DEV_2653&CC_0106=c:\drivers\m\in\1\iaahci.inf
PCI\VEN_8086&DEV_27C1&CC_0106=c:\drivers\m\in\1\iaahci.inf
PCI\VEN_8086&DEV_27C5&CC_0106=c:\drivers\m\in\1\iaahci.inf
PCI\VEN_8086&DEV_2681&CC_0106=c:\drivers\m\in\1\iaahci.inf
PCI\VEN_8086&DEV_2821&CC_0106=c:\drivers\m\in\1\iaahci.inf
PCI\VEN_8086&DEV_24DF&CC_0104=c:\drivers\m\in\1\O\iastor.inf
PCI\VEN_8086&DEV_25B0&CC_0104=c:\drivers\m\in\1\O\iastor.inf
PCI\VEN_10DE&DEV_008E=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_00D5=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_00EE=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_00E3=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_0036=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_003E=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_0054=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_0055=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_0266=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_0267=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_036F=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_037E=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_037F=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_03F6=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_03F7=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_10DE&DEV_03E7=c:\drivers\m\N\TM\nvatabus.inf
PCI\VEN_1039&DEV_0181=c:\drivers\M\SI\1\SISRaid1.INF
PCI\VEN_1039&DEV_0180=c:\drivers\M\SI\2\SISRaid.INF
PCI\VEN_1039&DEV_0182=c:\drivers\M\SI\3\SISRaid2.INF
PCI\VEN_1106&DEV_3349&CC_0104=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_6287&CC_0106=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_0591&CC_0104=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_3249&CC_0104=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_3149&CC_0104=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_3164&CC_0104=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_0581&CC_0104=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_7372&CC_0104=c:\drivers\M\V\1\VIAMRAID.INF
PCI\VEN_1106&DEV_4149=c:\drivers\M\V\2\viapide.inf
PCI\VEN_1106&DEV_0571=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_3149&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_0591&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_5337&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_3349&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_5287&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_3164&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_0581&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_1106&DEV_5324&CC_0101=c:\drivers\M\V\3\vminiide.inf
PCI\VEN_104B&DEV_1040=c:\drivers\M\VM\vmscsi.inf


These are the drivers I loaded, including SATA drivers of nforece, intel, via, sis, ali, amd. If other drivers need to be loaded, you can refer to the DriverPack_MassStorage_wnt5_x86-32.ini file in the driver pack.
4. Create the i386\$oem$ directory under the c:\sysprep directory, and create the cmdlines.txt file in c:\sysprep\i386\$oem$, and add the following content in the file

"c:\sysprep\sysprep -clean"

In this way, all mass storage controllers that are not installed because they do not exist on the target computer will be disabled during the minimal installation process.

5. Finally, execute sysprep to encapsulate. During the encapsulation process, the system will automatically install the SRS drivers. During the minimal installation, the redundant drivers will be deleted.

The advantage of this is that you can control the loaded drivers according to your own needs, and the disadvantage is that it is more troublesome to add manually.


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 ]
Floor 2 Posted 2007-06-03 15:09 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
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.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2007-06-03 15:14 ·  中国 四川 成都 电信
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Don't use difficulty to scare people

findstr /r /i "PCI\\VEN.*&DEV_"

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 4 Posted 2007-06-03 15:20 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
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...
Floor 5 Posted 2007-06-03 15:39 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
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.


@echo off
for /f "delims=: tokens=1*" %%a in ('findstr /sirc:"^PCI\\\VEN_....&" C:\SRS-DRV\*.inf') do (
echo\%%b=%%a>>1.txt
)
start 1.txt
Floor 6 Posted 2007-06-03 15:44 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
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 ]
Floor 7 Posted 2007-06-03 15:49 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by wudixin96 at 2007-6-3 15:44:
Why are there three \ in PCI\\\VEN? Isn't it two?

Moreover, the structure in the inf file is like this %DEVICE_DESCRIPTION% = Install, PCI\VEN_13C1&DEV_1002&SUBSYS_100213C1
It doesn't start with PCI\VEN.


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:

The content to be extracted has several similar characteristics:
1 All start with PCI\VEN.
Floor 8 Posted 2007-06-03 19:07 ·  中国 湖南 永州 电信
初级用户
Credits 68
Posts 32
Joined 2006-10-20 12:14
19-year member
UID 67277
Status Offline
Originally posted by namejm at 2007-6-3 15:09:
No one paid any attention after being left for so long, so I'll give it a try.

First, I would like to ask the original poster: "The previous part was extracted from the file", what exactly does this file look like? You'd better post it as an attachment.


The file used is the one downloaded from the link at the bottom of the first floor.
Floor 9 Posted 2007-06-03 19:10 ·  中国 湖南 永州 电信
初级用户
Credits 68
Posts 32
Joined 2006-10-20 12:14
19-year member
UID 67277
Status Offline
Originally posted by electronixtar at 2007-6-3 15:14:
Don't use difficulty to scare people

findstr /r /i "PCI\\VEN.*&DEV_"


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 ]
Floor 10 Posted 2007-06-03 19:23 ·  中国 湖南 永州 电信
初级用户
Credits 68
Posts 32
Joined 2006-10-20 12:14
19-year member
UID 67277
Status Offline
Originally posted by wudixin96 at 2007-6-3 15:44:
Why are there three backslashes in PCI\\\VEN? Shouldn't there be two?

Also, 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...


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.
Floor 11 Posted 2007-06-03 19:32 ·  中国 湖南 永州 电信
初级用户
Credits 68
Posts 32
Joined 2006-10-20 12:14
19-year member
UID 67277
Status Offline
Originally posted by lxmxn at 2007-6-3 15:39:
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.


@echo off
for /f "delims=: tokens=1*" %%a in ('findstr /s ...



I'm sorry, I didn't notice. I have re-modified the first post. :D
Floor 12 Posted 2007-06-04 16:28 ·  中国 湖南 永州 电信
初级用户
Credits 68
Posts 32
Joined 2006-10-20 12:14
19-year member
UID 67277
Status Offline
Waited all day and no one bumped it, so I'll do it myself
Floor 13 Posted 2007-06-04 16:34 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Is the version by moderator lxmxn not already prepared?
Floor 14 Posted 2007-06-04 16:38 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by baikaifang at 2007-6-4 16:28:
Waited all day and no one bumped it, so I'll do it myself

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.
Floor 15 Posted 2007-06-04 18:03 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
@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?
Forum Jump: