Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have several video files in a directory and I want to convert all of them into other video formats.
Is there any way that I can convert all of them in just one go using FFMPEG. I mean without having to make a shell script for doing so.

share|improve this question
What about a simple for loop? for i in *.mkv;do ffmpeg -i "$i" …;done – Marco Jul 22 '12 at 15:14

2 Answers 2

up vote 3 down vote accepted

The easiest way would be to use a for loop of your shell of choice. This task is so simple, you can just use the prompt, there's no need to create a shell script.

Here is the one-liner as an example for the widely-used bash (and compatible):

for i in *.mkv; do ffmpeg -i "$i" … ;done
share|improve this answer
Thanks, that's what I did. – Hamed Momeni Jul 22 '12 at 18:04

I just did such a conversion starting from Marco's solution. I added changing the file extension, in my case, from .mp4 to .mp3:

for i in *.mp4; do ffmpeg -i "$i" -codec:a mp3 "mp3/${i%.mp4}.mp3";done
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.