There are a few few ways to replace spaces with underscores. Below is one example where the files with spaces are created in the directory /home/flip/testdir, the "find and rename" command is used to make the change, and then ls is run to check that the spaces have indeed been replaced by underscores:
Code:
[flip@flop ~]$ cd /home/flip/testdir ; touch "file a" "file b" "file c"
[flip@flop ~]$ ls
'file a' 'file b' 'file c'
[flip@flop ~]$ find /home/flip/testdir -name "* *" -type f | rename 's/ /_/g'
[flip@flop ~]$ ls
file_a file_b file_c
Bear in mind that if /home/flip/testdir had directories beneath it with filenames which had spaces, that these also would be altered to replace those spaces with underscores, so the effect of the find command is recursive in that respect.