BAT批處理提取檔案內容替換指定檔案內容
從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 Enabledelayedexpans