用wildchar替换带有cmd的字符串

用wildchar替换带有cmd的字符串,cmd,substitution,Cmd,Substitution,我随身携带一个文本文件,其中包含一些行 line1 line2 helloabcd line4 我想创建一个批处理文件来编辑helloabcd行,比如说%this%,但我不知道abcd是什么,我只知道hello。那我怎么做呢 我试着使用fart.exe,但当有通配符时,它从未被替换 fart.exe txt1.txt hello* %this% 可以使用纯cmd,甚至是屁来完成吗 提前感谢您的回复 编辑:ok尝试了fart.exe txt1.txt你好%this%但是现在我得到了%this%

我随身携带一个文本文件,其中包含一些行

line1
line2
helloabcd
line4
我想创建一个批处理文件来编辑helloabcd行,比如说
%this%
,但我不知道
abcd
是什么,我只知道
hello
。那我怎么做呢

我试着使用fart.exe,但当有通配符时,它从未被替换

fart.exe txt1.txt hello* %this%
可以使用纯cmd,甚至是屁来完成吗

提前感谢您的回复

编辑:ok尝试了
fart.exe txt1.txt你好%this%
但是现在我得到了
%this%abcd
而不是
%this%
试试这个:

@echo off &setlocal
set "this=wqreqwrq"
for /f "delims=" %%i in ('^<txt1.txt findstr /n "^"') do (
    set "line=%%i"
    setlocal enabledelayedexpansion
    set "line=!line:*:=!"
    if not "!line!"=="!line:hello=!" set "line=%this%"
    (echo(!line!)>>output.txt
    endlocal
)
@echo off&setlocal
设置“this=wqreqwrq”

对于/f“delims=”%%i in(“^What is
%this%
在此设置中是什么?批处理变量还是字符串?字符串
设置this=wqreqwrq
好的批处理变量包含字符串。如果不是
hello
,而是由用户输入的
设置/p替换=输入要替换的内容
您可以将搜索字符串也放在变量中:
设置/p搜索=输入要搜索的内容:“
如果不是”!line!”==“!line:%search%=!”…