我有一个名为config.txt的文本文件 这是文件中包含的内容:
FacotyReset = No Size = 15 Line = 12 MarkValue = 22
我想在txt中搜索找到相应的值... ex。在这种情况下,大小等于15并将其更改为20.
答案 0 :(得分:0)
@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