Batch file 批处理文件查找包含子字符串并分配给变量的字符串

Batch file 批处理文件查找包含子字符串并分配给变量的字符串,batch-file,Batch File,我正在尝试创建一个批处理文件,该文件将在文件中查找字符串并用新值替换它 例如 test.txt包含若干行,其中包含YYYYMMDD可能不同的以下文本: "location":"/test/update_20130723/update_20130723.txt" "/test/update_20130723/update_20130724.txt", "/test/update_20130723/update_20130725.txt" 我想让批处理文件更新test.txt,其中的“update

我正在尝试创建一个批处理文件,该文件将在文件中查找字符串并用新值替换它

例如

test.txt包含若干行,其中包含YYYYMMDD可能不同的以下文本:

"location":"/test/update_20130723/update_20130723.txt"
"/test/update_20130723/update_20130724.txt",
"/test/update_20130723/update_20130725.txt"
我想让批处理文件更新test.txt,其中的“update_*”和“update_20130726”

这是我的测试。蝙蝠:

set newFilename="/test/update_20130726/update_20130726.txt"

for /f "tokens=* delims= " %%a in (test.txt) do (
set str=%%a
set str=!str:"update_*/update_*.txt"=%newFilename%!
echo !str!>> newfile
)
当我尝试运行此代码时,test.txt没有更新任何内容


提前感谢。

要使用repl添加命令,请执行以下操作:

repl.bat也可以在这里找到-


可以使用repl.bat查找所有“NUL”值(其中“NUL”的十六进制值为00)并替换为空空间吗?我尝试了键入“test.txt”| repl“00”“mx\xnn>update_test.txt,但似乎无法正常工作。
键入“test.txt”| repl“\x00”“mx>“update_test.txt”
type "test.txt" | repl "(update_........)" "update_20130726" m >"file.txt"