Replace a value between 2 fixed text

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
FreakyBird
Posts: 3
Joined: 22 Aug 2021 17:57

Replace a value between 2 fixed text

#1 Post by FreakyBird » 22 Aug 2021 18:20

Hello all,

I'm trying to replace a value wich is in a Filename.cfg wirch look like this :

Code: Select all

<config>
        <bool name="audio.bgmusic" value="false" />
	<bool name="global.achievements" value="true" />
	<string name="SystemsAuto" value="" />
	<string name="FolderViewMode" value="always" />
	<string name="Hiddenfeatures" value="freaky bird;super;beautiful;great;always joyfull" />
	<string name="Console Retro.ShowFlags" value="auto" />
	<string name="GamelistViewStyle" value="HCoinSpin" />
</config>
My goal is to replace the value wich is between quot one the line : <string name="Hiddenfeatures" value="freaky bird;super;beautiful;great;always joyfull" /> replaced by <string name="Hiddenfeatures" value="freaky bird;super;always joyfull" /> or any other value. This value change everytime.

I have tried with Jrepl :

Code: Select all

setlocal enableDelayedExpansion
set "newValue=myNewValue"
type "settings.cfg"|jrepl "(<string name="Hiddenfeatures" value=").*(" />)" "$1!newValue!$2" >fileName.cgf.new
REM move /y "fileName.cgf.new" "fileName.xml"
But it doesn't work since it do nothing on the file : no replacement. When i tried on small text without " " it works. So i think the quote are the problem but i don't know how to solve it and my english is poor :(

Thanks in advance if you can help !
Last edited by aGerman on 23 Aug 2021 10:07, edited 1 time in total.
Reason: code formatting

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Replace a value between 2 fixed text

#2 Post by aGerman » 23 Aug 2021 10:32


Post Reply