@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('dir /ad/b/s^|sort /r') do (
set b=%%~nxi
set b=!b: =_!
echo %%i
echo !b!
ren "%%i" !b!
)
endlocal
pause
复制以上代码保存到文本中并修改txt为bat
"set b=!b: =_!" 将空格替换成"_"下划线