if [ ! -d "$1" ]; then
echo $1 must be dir
else cd "$1"
for f in $(/bin/ls * | grep " "); do
nwName=$(echo "$f" | sed -e "s/ /_/g")
mv "$f" "$nwName"
Im running Bash on Linux and Windows, so this should work crossplatform, just check before deploying it, and use quotes or backslashes when entering wintendo dirnames with spaces.
It's a kinda crude solution, but it works for me.
Save this as something like "spc2uscore.sh" and invoke with the path+dirname as the single argument, changes every filename with spaces in that dir to filenames with underscores.