我正在运行一个批处理文件以使用 FFMPEG 转换目录中所有扩展名为 *.MTS 的文件。
for %%A in (*.MTS) do ffmpeg -i "%%A" -vcodec copy -acodec pcm_s16le -ar 48000 -ac 2 "newfiles\%%A.mov"
pause
输出文件转到一个名为 newfiles 的目录。转换没有问题。问题是如果输入是文件名.MTS 输出是文件名.MTS.mov
如何更改批处理文件,以便输入 name.MTS 输出为 name.mov?
最佳答案
除了正常for
循环变量,您还可以使用其他语法来更改输出。来自 for /?
的输出:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
因此,在您的情况下,您将使用
newfiles\%%~nA.mov
关于batch-file - 如何控制批处理文件中的输出文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41315486/