1.批量删除文件名中的指定字符
1 @echo off 2 Setlocal Enabledelayedexpansion 3 set "str=指定字符串" 4 for /f "delims=" %%i in ('dir /b *.*') do ( 5 set "var=%%i" & ren "%%i" "!var:%str%=!") 6 pause
2.按文件名称自动分类存放
@echo off setlocal enabledelayedexpansion dir /b *.pdf>list.txt for /f "tokens=1-3 delims=-" %%i in (list.txt) do ( set "Name=%%i-%%j-%%k" set "dirName=%%i" if not exist "!dirName!" md "!dirName!" move "!Name!" "!dirName!" ) del list.txt pause
说明:文件名格式及效果如下:
努力不给自己一点懒惰的理由,否则你会一蹶不振