The following command searches for all files that have a space in their name (find) and for each one it finds them (while) it renames them (actually moves them with mv) replacing each space with an underscore (tr).
find . -depth -name '* *' \ | while read f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done
Author: Lucas Vieites ✦ Published: ✦ Updated: ✦
