youtube-dl 不适用于 .bat 文件

Blr*_*lrp 3 windows command-line batch-file youtube-dl

我想用 .bat 文件处理我的 youtube 下载,如下所示:

youtube-dl -o path\%(title)s.%(ext)s --audio-format best -x ^
url
Run Code Online (Sandbox Code Playgroud)

它在 cmd 中运行良好,但是当我将它放入 .bat 并运行它时,我得到以下信息:

Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: Cannot download a video and extract audio into the same file! Use "path\(ext)s.%(ext)s" instead of "path\(ext)s" as the output template
Run Code Online (Sandbox Code Playgroud)

我可以通过替换%(title)s.%(ext)s来让它工作%(title)s%(ext)s.%(ext)s。当我运行 .bat 时,cmd 会像这样解释它:

youtube-dl -o path\(ext)s.(ext)s --audio-format best -x url
Run Code Online (Sandbox Code Playgroud)

我得到一个名为(ext)s.m4a.

如何使用我想要的路径获取正确命名的文件?

TOO*_*GAM 5

命令 shell 可能会将百分号和其他一些东西解释为变量名。如果您希望程序接收实际的百分号,您可能需要使用多个百分号对其进行转义。因此,请尝试连续使用两个百分号。

如果您使用该echo命令,您可以轻松查看实际发送给程序的内容(因此您可以查看程序实际接收的内容),这可能会有所帮助。