This batch file should do the trick:
if %1.==. .or. %2.==. (echo usage: %0 ini_name section_name & quit)
setlocal
set found_section=0
copy %1 %1.bak
del /q %1
set h=%@fileopen[%1,w]
:: turn off special character handling like pipes and redirection
setdos /x-456
:: iterate through every line in the original INI file
do l in @%1.bak
iff %found_section then
:: section names always begin with a [.
:: That's how we recognize the end of
:: the section (by the start of the next).
iff "%@left[1,%l]" == "[" then
set found_section=0
else
::skip over the lines in this section
iterate
endiff
endiff
:: If we find the section name then turn on
:: the flag that tells us to not copy those lines
iff %l == [%2] then
set found_section=1
iterate
endiff
:: otherwise, copy all the lines before and
:: after the section
set r=%@filewrite[%h,%l]
enddo
set r=%@fileclose[%h]
endlocal
-Scott
"JP Software Forums" <
[email protected]>
11/13/2008 12:33 PM
Please respond to
To
[email protected]
cc
Subject
RE: [Support-t-638] Remove a section from an INI file
thedave wrote:
|
| I'm looking for a way to remove an entire section from an INI file
| including the header, not just the individual keys and settings
| contained within, can anyone tell me if that's possible using
| internal commands or do I need to parse the INI file myself?
Sorry, you must do it yourself. The special functions for accessing INI
file
content, @INIREAD and @INIWRITE are very limited. What you need is an
@INIDELETE function, which could be built as a plug-in, but which nobody
has
created.
--
Steve