bat脚本实现替换含有=的字符串

1.需要把a=b替换为a=B,以下为1.txt文件内容:

123456
789
1=2
345=678
a=b
4=5
67890

2.bat替换脚本

@echo off&setlocal enabledelayedexpansion
if exist temp.txt del temp.txt
for /f "tokens=*" %%a in (1.txt) do (
set var=%%a

if "!var!"=="a=b" (
set var=a=B
)

echo.!var!>>temp.txt
)
move temp.txt 1.txt
pause