Computing.Net > Forums > Disk Operating System > Dos Batch Script with Type

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dos Batch Script with Type

Reply to Message Icon

Name: Argail
Date: November 4, 2003 at 04:04:00 Pacific
OS: Windows 2000
CPU/Ram: 1024
Comment:

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=Max

well 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
-_-



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: November 4, 2003 at 06:57:17 Pacific
Reply:

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


0

Response Number 2
Name: Argail
Date: November 4, 2003 at 08:16:54 Pacific
Reply:

perfect thanks =)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Bat file - print dir name... what do i do?



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Dos Batch Script with Type

DOS Batch Scripting www.computing.net/answers/dos/dos-batch-scripting/12777.html

Dos batch scripting www.computing.net/answers/dos/dos-batch-scripting/11369.html

DOS batch utility for type of pc www.computing.net/answers/dos/dos-batch-utility-for-type-of-pc/5000.html