вот так можно заменить строку в файле, не трогая другие строки
например, меняем Маня на Ваня
Код:

@echo off
set cоntext=Маня
set replace=Ваня
setlocal EnableDelayedExpansion
copy nul 5.out
for /F "delims=" %%s in (5.txt) do (
set string=%%s
set string=!string:%cоntext%=%replace%!
echo !string!>>5.out
)
move 5.out 5.txt
)