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.

In the terminal, I want to use ffmpeg2theora to convert all the .MOV files in a certain directory to .ogv files. However, the following does not work:

ffmpeg2theora *.MOV

Is there a good way to repeat a command multiple times on different files?

Thanks!

share|improve this question
add comment

2 Answers 2

up vote 18 down vote accepted

If you use the default shell (bash), you can use the following:

for file in *.MOV; do ffmpeg2theora "$file"; done
share|improve this answer
5  
This is more likely to work without the slashes: for file in *.[Mm][Oo][Vv]; do ffmpeg2theora "$file"; done –  frabjous Aug 7 '11 at 15:17
    
yes, you are absolutely right, I corrected my answer. –  Marcel Stimberg Aug 7 '11 at 15:24
1  
You could also set nocaseglob bash option to match lower-case, upper-case a mixed-case file extensions. –  enzotib Aug 7 '11 at 17:29
    
Thank you! I've never used bash before but it looks really useful. (Time for me to go learn!) –  Alan C Aug 8 '11 at 15:16
add comment

find . -iname '*.mov' -exec ffmpeg2theora '{}' \;

To limit recursion depth, you can add -maxdepth 1 before -exec

share|improve this answer
1  
Just to state the difference between this answer and my answer: Using find will also look for files in subdirectories, the for file in *.MOV solution will only look in the current directory. –  Marcel Stimberg Aug 8 '11 at 17:24
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.