Doing some reading here and here I found this solution to replace two underscores in filenames with only one using bash:
for file in *; do
f=${file//__/_}
echo $f
done;
However how do I most easily expand this expression to replace an arbitrary number of underscores with only one?