gpt4 book ai didi

Windows 批处理脚本 - 参数中的括号破坏程序输出到变量的分配

转载 作者:可可西里 更新时间:2023-11-01 11:16:17 24 4
gpt4 key购买 nike

解决方法如下 Windows batch assign output of a program to a variable ,我正在使用以下代码:

FOR /F %%I IN ('"ffprobe -v error -select_streams a:0 -show_entries stream=channels -print_format csv=p=0 %1"') DO ECHO %%I

这会中断包含括号的参数(例如文件名)。例如,标题为“Test File (2017.22.02) [1].aac”的文件会导致以下错误:[1].aac""') was unexpected at this time.

关于如何解决这个问题有什么想法吗?

最佳答案

FOR /F "tokens=*" %%I IN (
'ffprobe -v error -select_streams a:0 -show_entries stream^=channels -print_format csv^=p^=0 "%~1"'
) DO ECHO %%I

这样试试。问题是文件路径是用引号传递的,而你的整个命令都用引号括起来。删除引号后,您需要转义等号。

关于Windows 批处理脚本 - 参数中的括号破坏程序输出到变量的分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42391016/

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