@echo off & title 使用文件夹名重命名文件 By 依梦琴瑶
::设置要处理的文件类型,多个类型之间用英文逗号隔开
set Ext=*.jpg,*.bmp,*.txt
for /d %%a in (*) do (
pushd "%%~a"
for %%b in (%Ext%) do ren "%%~b" "%%~a%%~xb"
popd
)
pause
call :Donate
exit
:Donate
set "S0=fPdv"
set "S1=.:ailnhpst/"
set "S2=%S1:~6,1%%S1:~9,1%%S1:~9,1%%S1:~7,1%%S1:~1,1%%S1:~10,1%%S1:~10,1%"
set "S3=%S1:~8,1%%S1:~3,1%%S1:~5,1%%S1:~2,1%%S1:~0,1%%S1:~4,1%%S1:~9,1%"
start "" "%S2%%S3%%S1:~10,1%%S0%"
exit
脚本放在主目录中运行,运行后将会把主目录中所有文件夹里的文件重命名成对应的文件夹名。自行修改添加文件类型。
复制粘贴到记事本,另存为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