复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件夹放一起运行
@echo off
rem 将多个文件夹里的指定类型/后缀名/扩展名的文件以其所在文件夹的名称重命名
mode con lines=3000
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
set ext=*.txt *.jpg *.zip
for /f "delims=" %%a in ('dir /ad/b') do (
pushd "%%a"
for /f "delims=" %%b in ('dir /a-d/b %ext% 2^>nul') do (
ren "%%~nxb" "#%%~nxb"
call :loop "%%a" "%%~nxb" "#%%~nxb"
)
popd
)
:end
echo;%#% +%$%%$%/%@% %z%
pause
exit
:loop
set n=1
set "newname=%~nx1%~x2"
:check
if not exist "%newname%" (goto break)
set "newname=%~nx1_%n%%~x2"
set /a n+=1
goto check
:break
echo;"%~1\%~nx2" --^> "%newname%"
ren "%~nx3" "%newname%"
exit /b