Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 9 down vote accepted

Try this

for i in *.mp4; do avconv -i "$i" -vcodec copy -ac 2 -strict experimental "out-$i.mp4" ; done
share|improve this answer
3  
In case of files with spaces, instances of $i usually need to be "quoted". –  user76204 Oct 22 '12 at 14:52
1  
yes, you are right; corrected. –  January Oct 22 '12 at 16:19
add comment

Install ConvertMe!

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

enter image description here

DOWNLOAD

share|improve this answer
1  
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? –  WarriorIng64 Oct 22 '12 at 14:09
2  
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
1  
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
add comment

Your Answer

 
discard

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.