Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Heya i got the following problem. I have a file (.ini) where i want to change 4 lines with a batch script. Those lines look like this:
[w_zei_frame]
x=-18
y=-16
windowstate=Maxwell it would be easy if the x, y and windowstate values would stay the same. But they can change. And to make it even more tricky there are several entries in the whole file with x and y values.
Till now i got this far
type test.txt | find /V /I "[w_zei_frame]" > test1.txt
then i take the test1 file and add the right lines with the values to it and overwrite the test file with it. That works allright
but i m missing the x,y and windowstate values now.Is there a way to find a string which consists of 4 lines? or .... take the string and the 3 following lines to it or something like that?
Cause i guess there s no way to find the x y lines with find or type command. Even fc doesn t work cause of the other values. And before you ask no it HAS to be a batch script without any other programs involved whatsoever except ones i make myself :)Thanks in front for yer help
-_-

The script you find below strips from your .ini file the four lines starting with the header [w_zei_frame] storing the balance of the input in an output file ready to be refilled with the desidered stripped values.
To run type Xini File_In File_Out where File_In is the .ini to be parsed and File_Out your stripped result (e.g. Xini Text.ini Text.out). Xini is the name I assigned to the batch, but you can choose what you want.
It works only under NT-kernel systems (Windows NT/2K/XP) and if you need more support post again.
@Echo Off
Set FlOut=%2
Set Count=0
Echo. > %FlOut%For /F "tokens=*" %%A in (%1) Do Call :STRIP %%A
Set Count=
Set FlOut=
GoTo :EOF:STRIP
If /I "%1"=="[w_zei_frame]" (Set Count=3&GoTo :EOF)
If %Count% gtr 0 (Set /A Count=%Count%-1&GoTo :EOF)
Echo %* >> %FlOut%
GoTo :EOF

![]() |
Bat file - print dir name...
|
what do i do?
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |