如何将每个 ffmpeg 的批处理文件中的指定路径合并到其中?

如何将每个 ffmpeg 的批处理文件中的指定路径合并到其中?

如果我在所有电影所在的目录中使用 CMD 使用它,它可以正常工作:

for %i in (*.mp4) do ffmpeg -i "E:\%i" -map 0 -c copy -metadata:s:a:0 language=eng "E:\converted\%~ni.mp4"

我正在尝试创建一个批处理文件,允许用户输入源目录和输出目录。这行不通:

set /p filepath=Source File Path
set /p filepath2=Destination File Path
for %i in (*.mp4) do ffmpeg -i "%filepath%\%i" -map 0 -c copy -metadata:s:a:0 language=eng "%filepath2%\%~ni.mp4"

给出错误:

Error: The following usage of the path operator in batch-parameter substitution is invalid: %~ni.mp4"

答案1

如何在批处理文件中加入指定路径

在批处理文件中,你需要将 加倍%。例如:

for %%i in (*.mp4) do ffmpeg -i "%filepath%\%%i" -map 0 -c copy -metadata:s:a:0 language=eng "%filepath2%\%%~ni.mp4"

当用作批处理文件中的 FOR 命令的一部分时,需要两个 %

来源:参数/参数 - Windows CMD - SS64.com


进一步阅读

相关内容