浮生若梦——Galois21 Windows下批量对文件重命名 http://blog.galois21.com/archives/712
一.批量清除文件名中含有空格的文件
@echo off&setlocal enabledelayedexpansion for /f "delims=" %%i in ('dir /s/b *.*') do ( set "foo=%%~nxi" set foo=!foo: =! set foo=!foo: =! ren "%%~fi" "!foo!" ) pause
二.批量去除文件名中的某些字符串
@echo off set /p str1= Please enter the file (folder) name string (interchangeable space) to be replaced: set /p str2= Please enter the name string of the replaced file (folder) (Enter directly if removed): echo. echo Please wait while changing the name of the file (folder)!!!! 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