How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?
windows:
@echo off
for /r %%d in (*.wav) do (
ffmpeg -i "%%~nd%%~xd" -codec:a libmp3lame -c:v copy -qscale:a 2 "%
%~nd.2.mp3"
)
this is variable bitrate of quality 2, you can set it to 0 if you want but unless you have a really good speaker system it's worthless imo
To convert with subdirectories use e.g.
find . -exec ffmpeg -i {} {}.mp3 \;
This is what I use to batch convert avi to 1280x mp4
FOR /F "tokens=*" %%G IN ('dir /b *.avi') DO "D:\Downloads\ffmpeg.exe" -hide_banner -i "%%G" -threads 8 -acodec mp3 -b:a 128k -ac 2 -strict -2 -c:v libx264 -crf 23 -filter:v "scale=1280:-2,unsharp=5:5:1.0:5:5:0.0" -sws_flags lanczos -b:v 1024k -profile:v main -preset medium -tune film -async 1 -vsync 1 "%%~nG.mp4"
Works well as a cmd file, run it, the loop finds all avi files in that folder.
calls MY (change for yours) ffmpeg, passes input name, the settings are for rescaling up with sharpening. I probs don't need CRF and "-b:v 1024k
"...
Output file is input file minus the extension, with mp4 as new ext.
@Linux To convert a bunch, my one liner is this, as example (.avi to .mkv) in same directory:
for f in *.avi; do ffmpeg -i "${f}" "${f%%.*}.mkv"; done
please observe the double "%%" in the output statement. It gives you not only the first word or the input filename, but everything before the last dot.
If you want a graphical interface to batch process with ffmpegX, try Quick Batcher. It's free and will take your last ffmpegX settings to convert files you drop into it.
Note that you can't drag-drop folders onto Quick Batcher. So select files and then put them through Quick Batcher.
And for Windows, this does not work
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec mp3 "%~nG.mp3"
even if I do double those %
.
I would even suggest:
-acodec ***libmp3lame***
also:
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec libmp3lame "%~nG.mp3"