@echo off set "str1=需要替换的关键字" set "str2=替换后的关键字" Setlocal Enabledelayedexpansion for /f "delims=" %%i in ('dir /b *.*') do ( set "var=%%i" & ren "%%i" "!var:%str1%=%str2%!")
批量文件夹名关键字替换
1 2 3 4 5 6
@echo off set "str1=需要替换的关键字" set "str2=替换后的关键字" Setlocal Enabledelayedexpansion for /f "delims=" %%i in ('dir /a:d /b') do ( set "var=%%i" & ren "%%i" "!var:%str1%=%str2%!")
批量文件名关键字删除
1 2 3 4 5
@echo off set "str=需要删除的字符串" Setlocal Enabledelayedexpansion for /f "delims=" %%i in ('dir /b *.*') do ( set "var=%%i" & ren "%%i" "!var:%str%=!")
批量文件夹名关键字删除
1 2 3 4 5
@echo off set "str=需要删除的关键字" setlocal EnableDelayedExpansion for /f "delims=" %%i in ('dir /a:d /b') do ( set "var=%%i" & ren "%%i" "!var:%str%=!")