11

I've been trying to convert entire folders of files using ffmpeg for a long time now. I've searched the web, found various answers, but none that helped me. Currently I'm using multiple instances of ffmpeg to convert more than one file at a time. But it's very time consuming and annoying to type in everything all the time, even with copy/paste.

To simplify my current code it would look something like this. I specify the input file and the output format (+ various settings):

 ffmpeg -i "EXAMPLE.avi" newEXAMPLE.mp4

But what I would like is a single instance of ffmpeg to convert all files in a specific folder to a new format and for the files to keep their original name.

example1.avi > example1.mp4

example2.avi > example2.mp4

example3.avi > example3.mp4

and so on...

PS. I'm a bit new to these kind of things, so I'd much appreciate an explanation with your answer, so I can understand and learn. Thank you!

1
  • I believe this is what you're looking for stackoverflow.com/a/74585087/11814361 This works for videos in subdirectories as well :) Commented Mar 30, 2023 at 18:59

3 Answers 3

19
for /f "tokens=1 delims=." %a in ('dir /B *.avi') do ffmpeg -i "%a.avi" "%a.mp4"

This is for cmd window usage, if you want to use it in the batch script, than double all percent signs. You have run it in directory where your videos reside.

Sign up to request clarification or add additional context in comments.

Comments

11

In order to make ffmpeg batch encoding easier for Windows users, I developed this free open-source application using .NET/C#. I would like to include it here as an addtional choice to make things easier for some Windows users who may not be so familiar with command-line operation.

https://sourceforge.net/projects/ffmpeg-batch

2 Comments

Even with being very familiar with ffmpeg, this is great! It seems to be faster than doing the same thing by command line too, for whatever reason.
Well, that's surprising :)
9

If you have multiple periods in your file names, you can use this method instead:

for /r C:\path\ %a in (*.avi) do ffmpeg -i "%a" "%~pa%~na.mp4"

Just edit "C:\path\" as necessary.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.