I have put this question in the wrong forum. re-posting it here:
I am trying to change the project version in a xml file
using dos. when i execute the following code, an empty new.xml is created..there is nothing on the stdout as well. plz help
——
setLocal EnableDelayedExpansion > new.xml
for /f “tokens=* delims= ” %%a in (%1) do (
echo %%a
if %%a equ “^<currentVersion^>3.0.0^</currentVersion^>” (
echo ^<currentVersion^>3.0.0.1^</currentVersion^> >>new.xml
) else (
echo %%a
echo %%a>> new.xml
)
spaces or tabs and spaces or tabs on otherwise empty lines.
I am hoping this should deal with that:
@echo off rem !'s are important setlocal disabledelayedexpansion > new.xml for /f "skip=2 delims=" %%a in ('find /n /v "" "%~1"') do ( set line=%%a set test=%%a setlocal enabledelayedexpansion if defined test set test=!test:*]=! if defined test set test=!test: =! if defined test set test=!test: =! if /i "!test:<currentVersion>3.0.0</currentVersion>=!"=="" ( echo matchhhhhh set line=!line:*]=! >> new.xml echo !line:3.0.0=3.0.0.1! ) else ( rem delex var + substring + echo. don't like each other. if "!test!"=="" ( >> new.xml echo. ) else ( >> new.xml echo !line:*]=! ) ) endlocal ) endlocalBatch Variable how to