时间:2022-08-21 09:59:00 | 栏目:DOS/BAT | 点击:次
@echo off setlocal enabledelayedexpansion set /p str=请输入要删除的字符(回车确认): for /f "delims=" %%a in ('dir /a-d/b *') do ( set new=%%~a ren "!new!" "!new:%str%=!") echo 字符“%str%”已删除!&pause
@echo off setlocal enabledelayedexpansion echo "请输入所要添加的标题前缀[不添请回车]" set /p str1= echo "请输入所要添加的标题后缀[不添请回车]" set /p str2= :chose echo "是否应用到子文件夹中(Y/N)" set /p cho= if "%cho%"=="Y" goto 1 if "%cho%"=="y" goto 1 if "%cho%"=="N" goto 2 if "%cho%"=="n" (goto 2) else (goto chose) :1 for /f "delims=" %%i in ('dir /a-d/b/s') do (if /i not "%%~fi"=="%~f0" ren "%%i" "%str1%%%~ni%str2%%%~xi") goto 3 :2 for /f "delims=" %%i in ('dir /a-d /b *.*') do (if /i not "%%~fi"=="%~f0" ren "%%i" "%str1%%%~ni%str2%%%~xi") goto 3 :3 pause
@echo off& setlocal enabledelayedexpansion for /f "delims=" %%1 in ('dir /a /b') do (set wind=%%1 ren "%%~1" "!wind:OPE_=!") 注解:OPE_为自己想要删除的文件名前缀
@echo off set /p w=请输入文件格式(即扩展名并以回车结束): set /p str1=请输入要修改的文字(以回车结束): set /p str2=请输入要改成的文字(若是删除则直接回车,以回车结束): for /f "delims=" %%i in ('dir /b /a-d "*.%w%"' ) do ( set str3=%%i setlocal EnableDelayedExpansion set "str3=!str3:%str1%=%str2%!" ren "%%i" "!str3!" endlocal ) pause
BAT批处理很厉害,这些都是网上找的代码,不可考