I have a batch script that can replace text, and I want it to replace strings that are followed by a newline of text below the original. An example would be as follows:
I have tried a number of newline commands used in batch (some of which are found on Stack Exchange sites) and none of them work. I believe it is because of the syntax of the script. Here is the script I am working with:
@echo off setlocal enableextensions disabledelayedexpansion set search=Old string set replace=New string set textFile=Test.txt :PowerShell SET PSScript=%temp%\~tmpStrRplc.ps1 ECHO (Get-Content "%~dp0%textFile%").replace("%search%", "%replace%") ^| Set-Content "%~dp0%textFile%">"%PSScript%" SET PowerShellDir=C:\Windows\System32\WindowsPowerShell\v1.0 CD /D "%PowerShellDir%" Powershell -ExecutionPolicy Bypass -Command "& '%PSScript%'" EXIT
How can I implement a newline "injection" in my script?