Batch file 如何使用ffmpeg批量转换文件?
我想使用ffmpeg将多个.mp4文件转换为.mp3。以下是我的想法:Batch file 如何使用ffmpeg批量转换文件?,batch-file,cmd,ffmpeg,Batch File,Cmd,Ffmpeg,我想使用ffmpeg将多个.mp4文件转换为.mp3。以下是我的想法: cd (the folder I want to use) set counter = 1 for /r %%file in (*) ( ffmpeg %%file -i "Track %counter%.mp3" set counter = counter + 1 ) 但它不起作用。我猜我犯了一些基本的语法错误,但我不知道是什么。我做错了什么 空格在变量分配中有意义,但在算术/a表达式中除外 ::更正确 设置/a计数器=
cd (the folder I want to use)
set counter = 1
for /r %%file in (*) (
ffmpeg %%file -i "Track %counter%.mp3"
set counter = counter + 1
)
但它不起作用。我猜我犯了一些基本的语法错误,但我不知道是什么。我做错了什么
/a
表达式中除外
::更正确
设置/a计数器=1
::由于/a
设置/a计数器=1(..)
中的扩展在for命令开始之前完成,为了避免此setlocal enabledelayedexpansions
或调用函数,也可以使用echo-before命令帮助调试:: cd (the folder I want to use)
set /a counter=1
for /r %%f in (*.*) do (
call :proc %%f
set /a counter=counter+1
)
:: to avoid to execute following functions
@goto :eof
:: functions
:proc
@echo ffmpeg -i %1 "Track %counter%.mp3"
@goto :eof
ffmpeg%%file-i“Track%counter%.mp3”
-->ffmpeg-i%%file“Track%counter%.mp3”
@echo off
mkdir converted
for %%a in ("*.mp4") do ffmpeg -i "%%a" -b:a 192K -vn "converted\%%~na.mp3"
pause