Peok,
If you had been a real Bash programmer, you'd program all this in a single line with lots of $, %, &, <, /, |, \, (), {} and ~. And I can read the script, so that is a bad sign.
Just kidding, I don't see anything wrong, this is the way I write it myself.
In addition I would have used:
$fname instead of $X as it is more descriptive
echo "now processing file $fname"
WVGAIN=/usr/bin/wvgain and then
$WVGAIN -a `dirname $X`/*.wv
to be able to replace this by WVGAIN=echo during debugging
log_out=/dev/stderr
to be able to change log_out for /dev/null or ~/mylog
and use debug statements like
echo "this is a debug statement" > $log_out
But that is pedantic and way beyond what ordinarily is used.
You might want to check "Programming with Style" in the Advanced Bash Scripting guide. The link is in my sig.
jlinkels