Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何从文本文件中获取值并将其作为变量存储在批处理脚本中?_Batch File_Variables_Text Files_Findstr - Fatal编程技术网

Batch file 如何从文本文件中获取值并将其作为变量存储在批处理脚本中?

Batch file 如何从文本文件中获取值并将其作为变量存储在批处理脚本中?,batch-file,variables,text-files,findstr,Batch File,Variables,Text Files,Findstr,如何使用批脚本从文本文件中获取特定值并将其存储在变量中 例如(input.txt) 从示例文本文件中获取“VRWTF4534024810”有什么想法吗 ***我使用的是Windows 10 64位操作系统 提前感谢。在命令行中 for /f "tokens=1-26" %a in ('findstr 0000: input.txt') do @echo %r & set var=%r 或在脚本中(双倍百分比) 我想这将有助于更好地理解代币和熟食 非常感谢您!但是你能为我解释一下这部分吗

如何使用批脚本从文本文件中获取特定值并将其存储在变量中

例如(input.txt)

从示例文本文件中获取“VRWTF4534024810”有什么想法吗

***我使用的是Windows 10 64位操作系统

提前感谢。

在命令行中

for /f "tokens=1-26" %a in ('findstr 0000: input.txt') do @echo %r & set var=%r
或在脚本中(双倍百分比)


我想这将有助于更好地理解代币和熟食

非常感谢您!但是你能为我解释一下这部分吗?“tokens=1-26”。谢谢~因为将字段映射到%a..%z(1-17,*)的循环迭代器名称%a 1-26也应该可以工作,
获取/?
获取更多详细信息
for /f "tokens=1-26" %a in ('findstr 0000: input.txt') do @echo %r & set var=%r
for /f "tokens=1-26" %%a in ('findstr 0000: input.txt') do @echo %%r & set var=%%r