BAT批处理提取文件内容替换指定文件内容

版权声明:文章来源:良玉的博客 http://www.uouo123.com/ 转载请注明 https://blog.csdn.net/xiangliangyu2008/article/details/82711055

从test.txt里查找CLIENT_HOME 按=分割,获取值  替换1.txt里的所有CKIENT_HOME 

由于修改的文件xml,所以需要chcp 65001切换编码到utf8,否则会出现中文乱码

批处理bat:

adding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace, 'Microsoft YaHei'; white-space: pre-wrap; word-wrap: break-word; word-break: break-all; color: rgb(51, 51, 51); line-height: 20px;">

@echo off
chcp 65001

for /f "tokens=1,2 delims==" %%a in ('Type conf.properties^|Findstr CLIENT_HOME') do (
       set "c1=%%a" 
       set "new=%%b"
       goto end
       )
:end
echo %new%


ren cgame.as3proj a.txt
for /f "delims=" %%i in ('findstr "CLIENT_HOME" a.txt')do (
       for /f "delims=" %%j in ('type "a.txt"') do (
               if %%i==%%j (
                               setlocal Enabledelayedexpansion
                               set "var=%%i"
                       set "var=!var:CLIENT_HOME=%new%!"
                       echo !var!>>b.txt
                       endlocal
                       )else echo %%j>>b.txt
               )
       ) 
ren b.txt cgame.as3proj
del a.txt b.txt

pause

猜你喜欢

转载自blog.csdn.net/xiangliangyu2008/article/details/82711055