I'm working on a config installer for a game. I want to make a menu for the user to choose from different colors for certain settings. To change those colors I use a PowerShell command in a batch file to find and replace the relevant text in a specific file. There is no problem with that alone.
In the replacement process, PowerShell also replaces the newline character found in the config file with a "?". That is not intended and I want to avoid that.
The character that gets replaced with a "?" is the following:
↵
I want to exclude that character from getting replaced in the process.
My code looks like that:
powershell -command "& {($p=gc "path.txt");(gc $p\GameConfig\SpecificFile.txt).replace('<col:Default>','<col:Green>') | sc $p\GameConfig\SpecificFile.txt}"
I have already tried to exclude the character like so:
powershell -command "& {($p=gc "path.txt");(gc $p\GameConfig\SpecificFile.txt).replace[↵]::escape('<col:Default>','<col:Green>') | sc $p\GameConfig\SpecificFile.txt}"
That didn't work.
I also tried to revert the replacement process of the newline character like so:
powershell -command "& {($p=gc "path.txt");(gc $p\GameConfig\SpecificFile.txt).replace('<col:Default>','<col:Green>') | sc $p\GameConfig\SpecificFile.txt}"
powershell -command "& {($p=gc "path.txt");(gc $p\GameConfig\SpecificFile.txt).replace('>?<','>↵<') | sc $p\GameConfig\SpecificFile.txt}"
That didn't work either.
I really need some help. Thanks in advance!
Cheers