替换一个文件的字符串

::将sourcefile中的字段true替换为xxx
::该文件放在网管安装路径的根目录下即可

@echo off
setlocal enabledelayedexpansion
set dir=%CD%
set sourcefile=%dir%\...\mw-license-switch-conffile.xml
set targetfile=%dir%\...\mw-license-switch-conffile1.xml
for /f "delims=" %%i in ('type "%sourcefile%"')  do (
set str=%%i
set str=!str:true=charTobeModify!
echo !str!>>"%targetfile%"
)
del "%sourcefile%"
ren "%targetfile%" mw-license-switch-conffile.xml

 

posted @ 2017-06-12 16:48  laislabonita  阅读(461)  评论(0编辑  收藏  举报