@echo off
setlocal disableDelayedExpansion
if /i "%~1"=="/R" (
set "forOption=%~1 %2"
set "inPath="
) else (
set "forOption="
if "%~1" neq "" (set "inPath=%~1\") else set "inPath="
)
for %forOption% %%F in ("%inPath%* *") do (
if /i "%~f0" neq "%%~fF" (
set "folder=%%~dpF"
set "file=%%~nxF"
setlocal enableDelayedExpansion
set "newname=!file: = !"
echo ren "!folder!!file!" "!newname!"
ren "!folder!!file!" "!newname!"
endlocal
)
)
copy to above to removedoublespace.bat
removedoublespace.bat /r c:
remove all include subfolder
cr
https://stackoverflow.com/questions/11270453/how-to-remove-spaces-from-file-names-in-bulk