Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I'm new to Linux and I want to execute one command on every file in a loop:

avconv -i *.mp4 -vcodec copy -ac 2 -strict experimental *.mp4

Can any one tell me how I can do this? I have more than 100 files to convert. I just want to convert them into new files with the same names, but using different codecs. It works for one file but I don't know how to run it on all of the files. I found this avconv documentation but I can't find the answer in there either.

share|improve this question

2 Answers 2

up vote 16 down vote accepted

Try this:

for i in *.mp4; do avconv -i "$i" -vcodec copy -ac 2 -strict experimental "out-$i"; done
share|improve this answer
In case of files with spaces, instances of $i usually need to be "quoted". – user76204 Oct 22 '12 at 14:52
yes, you are right; corrected. – January Oct 22 '12 at 16:19
And it should be "out-$i" instead of "out-$i.mp4" unless you want to get files with *.mp4.mp4 extension ;) – Piotr Kukielka Apr 4 at 14:07

Install ConvertMe!

This is not the very best answer, but will help you somehow...

enter image description here


share|improve this answer
The OP mentioned they have over a hundred files to convert. Given that this is a GUI utility, would this be practical to use for converting that many files all at once without, i.e. excessive clicking? – Christopher Kyle Horton Oct 22 '12 at 14:09
This GUI integrates with Nautilus File manager allowing you to convert multiple files with a single click. Select all the files you want to convert > Right-click on one file> Goto Scripts > click Convert Video More information is available at the provided link. – Naveen Oct 22 '12 at 14:29
This is a Q&A site, not a place to advertise software. – Darkwater Jul 29 '13 at 16:29
That software is not for sale. It's not an advertisement. I said this is not the best answer above, but might help people who come here in future. – Naveen Aug 3 '13 at 5:16

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.