BAT批量对⽂件(夹)进⾏重命名亲测有效!
1. 新建记事本⽂件.txt;
2. 复制以下全部代码,保存⽂件;
3. 将⽂件名改为“批量重命名-替换⽂件或者⽂件夹字符串.bat”;
4. 把此⽂件拷贝到需要重命名的⽂件夹下(建议先备份原始⽂件,防⽌误操作造成丢失);
5. 双击运⾏,根据提⽰输⼊相应的名字;
6. 完成!
@echo off
:menu
set yn=Q
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo当前⽬录: %~dp0
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo【R】⽂件名字符替换
华为 mate8echo【X】⽂件名字符截取后添加
echo【Q】退出
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set /P yn=请选择:
if /i %yn%==R goto goRen
if /i %yn%==X goto goAdd
if /i %yn%==Q goto goEnd
exit
:goRen
echo如匹配[H][01].sc.[pop].tv 输⼊格式:[?][??].sc.[*].tv
echo如匹配[H][01].sc.[pop].tv 输⼊格式:[H][??].sc.[pop].tv
echo ? 代表匹配单个字符 * 代表匹配多个字符
set /p n=匹配格式:
set /p o=需要替换的字符:
set /p t=把%o%替换为:
setlocal enabledelayedexpansion
初中生考不上高中咋办for %%i in("%n%")do(
set old=%%i
set"new=!old:%o%=%t%!"
手机崔永元echo!old! ^>!new!
)
endlocal
set /p yn=确认 y:
if /i not %yn%==y goto menu
setlocal enabledelayedexpansion
for %%i in("%n%")do(
set old=%%i
set"new=!old:%o%=%t%!"
ren "!old!""!new!"
)
endlocal
goto menu
:goAdd
echo输⼊⽂件名匹配格式如查[H][01].sc.[p o p].tv 输⼊[?][??].sc.[*].tv set /p n=匹配格式:
set /p x=从⽂件名开始处截取的数量:
set /p a=截取之后添加的字符:
setlocal enabledelayedexpansion
for %%i in("%n%")do(
set old=%%i
set"new=!old:~0,%x%!%a%"
股市大跌原因echo!old! ^>!new!
)
endlocal
圈子是什么意思
set /p yn=确认 y:
磐安旅游if /i not %yn%==y goto menu
setlocal enabledelayedexpansion
for %%i in("%n%")do(
set old=%%i
set"new=!old:~0,%x%!%a%"
ren "!old!""!new!"
)
endlocal
goto menu
:goEnd
exit