Source: https://stackoverflow.com/questions/2709458/how-to-replace-spaces-in-file-names-using-a-bash-script
Install the package
apt-get install rename
Rename the dirs first, then the files
find -name "* *" -type d | rename 's/ /_/g' find -name "* *" -type f | rename 's/ /_/g'