文件名和文件夹的bat批量重命名替换关键字和删除关键字
批量文件名关键字替换
@echo offset "str1=需要替换的关键字"set "str2=替换后的关键字"Setlocal Enabledelayedexpansionfor /f "delims=" %%i in ('dir /b *.*') do (set "var=%%i" & ren "%%i" "!var:%str1%=%str2%!")
批量文件夹名关键字替换
@echo offset "str1=需要替换的关键字"set "str2=替换后的关键字"Setlocal Enabledelayedexpansionfor /f "delims=" %%i in ('dir /a:d /b') do (set "var=%%i" & ren "%%i" "!var:%str1%=%str2%!")
批量文件名关键字删除
@echo offset "str=需要删除的字符串"Setlocal Enabledelayedexpansionfor /f "delims=" %%i in ('dir /b *.*') do (set "var=%%i" & ren "%%i" "!var:%str%=!")
批量文件夹名关键字删除
@echo offset "str=需要删除的关键字"setlocal EnableDelayedExpansionfor /f "delims=" %%i in ('dir /a:d /b') do (set "var=%%i" & ren "%%i" "!var:%str%=!")