1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| @echo off set /p str1= 请输入要替换的文件(文件夹)名字符串(可替换空格): set /p str2= 请输入替换后的文件(文件夹)名字符串(若删除直接回车): echo. echo 正在操作中,请稍候…… for /f "delims=" %%a in ('dir /s /b ^|sort /+65535') do ( if "%%~nxa" neq "%~nx0" ( set "file=%%a" set "name=%%~na" set "extension=%%~xa" call set "name=%%name:%str1%=%str2%%%" setlocal enabledelayedexpansion ren "!file!" "!name!!extension!" 2>nul endlocal ) ) exit
|