0
我有一個名爲config.txt的 一個文本文件,這就是包含在文件中:搜索與TXT一個批處理文件,並替換值
FacotyReset = No Size = 15 Line = 12 MarkValue = 22
我想在搜索txt找到相應的值... ex。的大小,在這種情況下等於15,並將其改爲20.
我有一個名爲config.txt的 一個文本文件,這就是包含在文件中:搜索與TXT一個批處理文件,並替換值
FacotyReset = No Size = 15 Line = 12 MarkValue = 22
我想在搜索txt找到相應的值... ex。的大小,在這種情況下等於15,並將其改爲20.
@echo off
setlocal EnableExtensions EnableDelayedExpansion
>config.txt.tmp (<nul set /p "=")
for /f "delims=" %%A in (config.txt) do (
set "found=false"
for /f "tokens=1,2,3,*" %%W in ("%%A") do (
if "%%W"=="Size" (
echo %%W %%X 20 %%Z>>config.txt.tmp
set "found=true"
)
)
if "!found!"=="false" echo %%A>>config.txt.tmp
)
rem del config.txt
rem ren config.txt.tmp config.txt
endlocal
*嘆* [什麼](http://stackoverflow.com/search?q=windows+batch+replace)... [have](http://stackoverflow.com/search?q=batch+replace+line)... [you](https://www.google.com/search?q=windows%20batch%20replace%20text %20in%20file)... [試過](http://mattgemmell.com/2008/12/08/what-have-you-tried/)? – rojo 2013-03-04 13:36:24