I pity windows users on a daily basis for their lack of a easy-to-use, powerful, general purpose scripting language. Linux an Mac (owing to OS X's BSD heritage) have a a plethora from which to choose. It's gotten to the point where I cannot operate a computer without being able to script things... It is very difficult to suffer away on a Windows box that lacks cygwin.
There are at least two ways to make recursive bash scripts. The most obvious way is to just call itself (any bash script behaves just like any other command). For example, this would encode all wav files recursively in a directory tree (assume the script is named "mppall"):
CODE
#!/bin/bash
for file in *.wav; do
mppenc --standard --xlevel "$file"
done
for file in *; do
if [ -d "$file" ]; then
cd "$file"
mppall
cd ..
fi
done
You can also define functions. Functions act exactly like mini shell scripts that operate within other shell scripts and are called the same way as anything else. If you define a function in your .bashrc or .bash_profile (depending on your system, either may work, or just one...) it will be available in your shell environment and can be used like any other command. They can also call themselves recursively. This is the same script as the one above, except it uses a function and operates on it's command line parameters instead of the current directory.
CODE
#!/bin/bash
function mppdir() {
for file in "$1"/*.wav; do
mppenc --standard --xlevel "$file"
done
for file in "$1"/*; do
if [ -d "$file" ]; then
mppdir "$file"
fi
done
}
for param in "$@"; do
mppdir "$param"
done
It first defines the function, then calls it for every command line parameter. Isn't that just sexy? You could probably do the same thing with "find" but I did it this way to illustrate the scripting technique.