Doing it with
FEdit is too complex:
Editing text file from batch file
I have already used
SED for appending lines to an existing inf as posted
here
in this old archived post, i was adding new lines one by one.
SED allows to insert a block of lines before defined pattern with one command:
for updating HIVESFT.INF, i will add this 1st line to HIVESFT.TXT: /[AddReg.Upgrade]/ i
for updating HIVECLS.INF, i will add this 1st line to HIVECLS.TXT: /[DelReg]/ i
add backslash
\ at end of each line to be inserted (including the 1st).
special metacharacters like backslash \ or quote " need to be escaped with an added backslash
\
left [ and right ] square brackets are escaped with an added backslash \
Finally i will use
gsar.exe which is exactly the needed tool.
Quote
:// use charmap to find character hex code
:// search 'reverse solidus' and escape with 'reverse solidus'
gsar -s:x5c -r:x5c:x5c -o temp\hivecls.txt
:// search 'quotation mark' and escape with 'reverse solidus'
gsar -s:x22 -r:x5c:x22 -o temp\hivecls.txt
:// search 'carriage return' and add 'reverse solidus' before
gsar -s:x0d -r:x5c:x0d -o temp\hivecls.txt
:// search 4 blanks & 'Capital Letter H' and keep only 'Capital Letter H'
gsar -s:x20:x20:x20:x20:x48 -r:x48 -o temp\hivecls.txt
:// Header
:// search 'left square bracket' and escape with 'reverse solidus'
gsar -s:x5b -r:x5c:x5b -o temp\hivecls.txt
:// search 'right square bracket' and escape with 'reverse solidus'
gsar -s:x5d -r:x5c:x5d -o temp\hivecls.txt
:// sed don't support direct alteration of input files so output to intermediate file
sed -f temp\hivecls.txt i386\hivecls.inf >temp\hivecls.int
:// replace original hivecls.inf with intermediate file hivecls.int
copy /y temp\hivecls.int i386\hivecls.inf
This post has been edited by Bilou_Gateux: 12 February 2006 - 09:27 AM