"for i in *.mp3" doesn't work with spaces and some other "special" characters in filenames, see here:
http://unix.stackexchange.com/questions/9496/looping-through...
http://unix.stackexchange.com/questions/9496/looping-through...
for i in *.mp4; do ffmpeg -i "$i" "${i%.mp4}.mp3"; done
will result in executing: ffmpeg -i foo foo.mp3
ffmpeg -i bar.mp4 bar.mp3
Which is obviously not what was meant. So it's a good habit to learn to loop over files in a directory in a different way. $ function echon { echo $# $*; }
$ >'foo bar.mp4'
$ for i in *.mp4; do echon "$i" "${i%mp4}mp3"; done
2 foo bar.mp4 foo bar.mp3 for i in `find -name '*.mp4'`; do # ...
or similar. In that case, the output of `find` is indeed split first, and `for` sees "foo", "bar.mp4", and so on.