If you don't care about the order of the lines in the file, then you can use FINDSTR to strip out the old build.id line and write the result to a new file. Then append a new line with the new value. Finally move the new file to the original name.
@echo off
>file.txt.new (
findstr /vbl "build.id=" file.txt
echo build.id=NewValue
)
move /y file.txt.new file.txt >nul
If you want to preserve the line order, then use FOR /F to read each line, parsing the line into variable name and value. Then a simple IF statement can be used to process the line accordingly.
@echo off
>file.txt.new (
for /f "tokens=1* delims==" %%A in (file.txt) do (
if "%%A" == "build.id" (
echo build.id=NewValue
) else (
echo %%A=%%B
)
)
)
move /y file.txt.new file.txt >nul
Or you can make the task really simple by getting your hands on a utility that supports regular expression search and replace. I have written a hybrid JScript/batch utility called REPL.BAT that I find extremely useful. Here is how it could be used for your simple task.
@echo off
type file.txt | repl "^(build\.id=).*" "($1)NewVaue" >file.txt.new
move /y file.txt.new file.txt >nul