@echo off
setlocal enableextensions disabledelayedexpansion
set "root=c:\some\where"
for /r "%root%" %%a in ("*.?*.pdf") do (
set "filename=%%~na"
setlocal enabledelayedexpansion
for %%f in ("!filename:.= !") do (
endlocal
echo ren "%%~fa" "%%~f%%~xa"
)
)
This will recursively search under the indicated folder for files with .pdf
extensions, that include at least two dots. For each file found, aditional dots in the file name (extension excluded) are replaced with a space.
To avoid problems with exclamation points in file names or paths, delayed expansion (needed to modify a variable inside a block and access the changed value) is enabled to remove the dots and disabled before executing the rename operation.
Rename operations are only echoed to console. If the output is correct, remove the echo
command that precedes the ren