在执行bat之前,xml文件中是没有多余的空行,执行后就多了一个行出来了,如下图:
修改前:
修改后:
bat代码:
@echo off
setlocal enabledelayedexpansion
set fileName=D:\打包\Terminal\Config
cd /d %fileName%
for /f "skip=2 tokens=1-4 delims=^<^>" %%i in ('find /i "LossVersion" Config.xml') do (
set LossVersion=%%k
echo LossVersion当前值为!LossVersion!
)
for /f "skip=2 tokens=1-4 delims=^<^>" %%i in ('find /i "AppVersion" Config.xml') do (
set AppVersion=%%k
set /p str2=AppVersion修改为(当前值为:!AppVersion!):
)
chcp 65001
for /f "tokens=* delims=" %%a in (Config.xml) do (
set "content=%%a"
call set "content=%%content:<AppVersion>!AppVersion!</AppVersion>=<AppVersion>!str2!</AppVersion>%%"
call set "content=%%content:<LossVersion>!LossVersion!</LossVersion>=<LossVersion>!str2!</LossVersion>%%"
echo !content!>>result.xml
)
del Config.xml
ren result.xml Config.xml
chcp 936
pause
请教,我该如何修改,在修改xml文件后不多出最后一行。