Help with Replace Stringscript

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
robertpw123
Posts: 1
Joined: 24 Mar 2019 16:08

Help with Replace Stringscript

#1 Post by robertpw123 » 24 Mar 2019 16:14

Hello,
I've downloaded the following script from you guys

Code: Select all

REM -- Prepare the Command Processor --
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION

::BatchSubstitude - parses a File line by line and replaces a substring"
::syntax: BatchSubstitude.bat OldStr NewStr File
::          OldStr [in] - string to be replaced
::          NewStr [in] - string to replace with
::          File   [in] - file to be parsed
:$changed 20100115
:$source https://www.dostips.com
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
    set "line=%%B"
    if defined line (
        call set "line=echo.%%line:%~1=%~1.[%~2%%"
        for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
    ) ELSE echo.
)
and it's great but i can't insert a newline character.
I've been googleing a lot and still couldn't find a solution..
I also tried to edit the script to not replace a string but to simply add a new line but i can't get the right if statement to work.
Can you please help?
Thanks,
Robert

Post Reply