Windows控制台 - BAT兼容性

Mic*_*ael 3 windows ffmpeg batch-file command-prompt windows-console

我有一个命令行语句,当手动将其键入控制台时,它可以正常工作,但是,当我将它放入bat文件时,它不起作用.

for %f in (*.flac) do ffmpeg -i "%f" -acodec alac "%~nf.m4a"
Run Code Online (Sandbox Code Playgroud)

这是我尝试运行bat文件时的错误消息

The following usage of the path operator in batch-parameter
substitution is invalid: %~nf.m4a"
Run Code Online (Sandbox Code Playgroud)

有没有什么办法解决这一问题?该语句使用程序ffmpeg将flac文件转换为alac文件.

小智 7

解释批处理文件时,%%将替换为%,因此您的解决方案是将%f替换为%% f

  • 谢谢你,我不得不替换所有的%符号,而不仅仅是%f. (2认同)