Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 19 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
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
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

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

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

share|improve this answer
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

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.