gpt4 book ai didi

Windows 批处理 : Pipe output from exe into a SET VARIABLE where output has spaces

转载 作者:可可西里 更新时间:2023-11-01 11:52:47 26 4
gpt4 key购买 nike

有很多 Stack Overflow 文章与此相关,但没有直接的答案。

这条命令会输出一堆单词

OutputVariable.exe %FILEPATH%

输出:

Mary had a little lamb

在批处理文件中,这里是如何将输出放入变量

for /f %%i in ('OutputVariable.exe %FILEPATH%') do SET SENTENCE=%%i
ECHO %SENTENCE%

输出:

Mary

通常,FOR 命令会在空格处中断。帮助!

最佳答案

for /f "delims=" %%i in ('OutputVariable.exe %FILEPATH%') do SET "SENTENCE=%%i"
ECHO %SENTENCE%

; , = <space> <tab>是 batch 和 for /f 中的标准分隔符结果由他们自动拆分。要停用分隔符,您需要 "delims="for /f选项。

关于Windows 批处理 : Pipe output from exe into a SET VARIABLE where output has spaces,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25940920/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com