I need your help .... findrepl

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sosna
Posts: 2
Joined: 18 Feb 2015 09:47

I need your help .... findrepl

#1 Post by sosna » 18 Feb 2015 10:22

Hello All,
There is my problem:

I would like to modify *.ini file. I need modify three things - three steps code:

1. modify 2lines
2. add some text to line9.
3. remove line9




original ini:

Code: Select all

[OPTIONS]
GlobalDataPath=Y:
//GlobalDataPath=c:\Program Files\EM\_base_ladeni
OnStart=
OnExit=
ShowDebug=1
ActPhase=3
Sound=0

[EMs]
Enabled=0000000001000000000000000000000000000000
SaveReadOut=1
CheckIDDuplicit=1

[TEPLOMER]
Enabled=0
Default=23.0

[LAST_OPENED]
zak=LET13561.zak


1. modify 2lines :

Code: Select all

[OPTIONS]
GlobalDataPath=Z:
//GlobalDataPath=c:\Program Files\EM\_base_ladeni
OnStart=
OnExit=
ShowDebug=1
ActPhase=3
Sound=0

[EMs]
Enabled=0000000001000000000000000000000000000000
SaveReadOut=1
CheckIDDuplicit=1

[TEPLOMER]
Enabled=0
Default=23.0

[LAST_OPENED]
zak=LET13561.zak



2. add some text to line9:

Code: Select all

[OPTIONS]
GlobalDataPath=Z:
//GlobalDataPath=c:\Program Files\EM\_base_ladeni
OnStart=
OnExit=
ShowDebug=1
ActPhase=3
Sound=0
CheckedOperation="55"

[EMs]
Enabled=0000000001000000000000000000000000000000
SaveReadOut=1
CheckIDDuplicit=1

[TEPLOMER]
Enabled=0
Default=23.0

[LAST_OPENED]
zak=LET13561.zak



3. remove line9 : (remove: CheckedOperation="55")

Code: Select all

[OPTIONS]
GlobalDataPath=Y:
//GlobalDataPath=c:\Program Files\EM\_base_ladeni
OnStart=
OnExit=
ShowDebug=1
ActPhase=3
Sound=0

[EMs]
Enabled=0000000001000000000000000000000000000000
SaveReadOut=1
CheckIDDuplicit=1

[TEPLOMER]
Enabled=0
Default=23.0

[LAST_OPENED]
zak=LET13561.zak


I tried to use findrepl:

1. modify 2lines

Code: Select all

type "c:\Program Files\em\CalForm\CalForm.ini"|findrepl /LINE2 "GlobalDataPath=Y" "GlobalDataPath=Z" >"c:\Program Files\em\CalForm\CalForm.ini"


2. add some text to line9

Code: Select all

@echo off
 (
 type "c:\Program Files\em\CalForm\CalForm.ini"|findrepl /o:1:8
 echo CheckedOperation="55"     
 type "c:\Program Files\em\CalForm\CalForm.ini"|findrepl /o:9
) > "c:\Program Files\em\CalForm\CalForm.tmp"
type "c:\Program Files\em\CalForm\CalForm.tmp" >"c:\Program Files\em\CalForm\CalForm.ini"
del /q "c:\Program Files\em\CalForm\CalForm.tmp"


3. remove line9

Code: Select all

type "c:\Program Files\em\CalForm\CalForm.ini"|findrepl.bat /v /o:9:9 >"c:\Program Files\em\CalForm\CalForm.ini"


Everything works ok .... but sometimes findrepl generate bug :? :

C: \ Program Files \ EM \ CalForm \ findrepl.bat (784, 4) Microsoft JScript - Runtime Error: The input end of the file

What to do?

Thanks Sosna
(Win XP/SP3)

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: I need your help .... findrepl

#2 Post by dbenham » 18 Feb 2015 20:03

Not sure what is happening with FINDREPL.BAT, but you could try RJEPL.BAT instead:

Step 1:

Code: Select all

call jrepl "^(GlobalDataPath=).*" "$1Z:" /f "c:\Program Files\em\CalForm\CalForm.ini" /o -

Step 2:

Code: Select all

call jrepl "^" "CheckedOperation=\q55\q\r\n" /x /jbegln "skip=(ln!=9)" /f "c:\Program Files\em\CalForm\CalForm.ini" /o -

Step 3:

Code: Select all

call jrepl "^.*" "$0" /jmatch /jbegln "skip=(ln==9)" /f "c:\Program Files\em\CalForm\CalForm.ini" /o -


Dave Benham

sosna
Posts: 2
Joined: 18 Feb 2015 09:47

Re: I need your help .... findrepl

#3 Post by sosna » 23 Feb 2015 09:02

To: dbenham

Thanks a lot it worked perfect and reliably. :wink:

Post Reply