Short script, with a subroutine, to replace spaces in file names with underscores. The script runs recursively on directories and sub-directories.
Works on txt files, but can be anything, just change to
for /R %location% %%A in (*.txt) do call :repl "%%A"
ren %1 "%_fn: =_%"