I find it annoying to have file names with whitespace characters in them under Linux, because I mainly work in the shell (Bash in my case) and it always requires ugly escaping.
Here is my Bash solution to replace all spaces (‘ ‘) with underscores (‘_’) in all file and directory names in the current directory:
for FILE in *; do mv "$FILE" "$(echo $FILE | sed -e 's/ /_/g')"; done
You will get warnings for file names which do not contain any spaces, you can ignore those. Also note that this solution is not recursive, i.e., it does not descend into sub directories.