I am new to batch files and having trouble piecing together the last steps here. My goal is purely to insert 'Test4' inbetween 2 lines of text. The text never changes and is always line 1 and line 3 (line 2 is blank within the text file). The code removes line 2 (blank) but does not insert the text.
Current txt file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ProductDataeXchangePackage [
1
2
3
Current Batch script:
rem Saved in D:\Temp\WriteText.bat
echo off
setlocal enabledelayedexpansion
ren test.txt in.tmp
set p=
for /f "delims=" %%a in (in.tmp) do (
if "%%a"=="<!DOCTYPE_ProductDataeXchangePackage+[" if "!p!"=="<?xml version="1.0" encoding="UTF-8" ?>" Echo Test4 >> test.txt
Echo %%a >>test.txt
set p=%%a
)
del in.tmp