@echo off
setlocal enabledelayedexpansion
for /r "G:111" %%i in (*.*) do (
set b=%%~nxi
set b=!b: =_!
echo %%~dpi
echo !b!
echo %%~nxi
ren "%%i" !b!
)
endlocal
pause
复制以上代码保存到文本中并修改txt为bat
"G:111" 待处理文件所在的路径
"set b=!b: =_!" 将空格替换成"_"下划线