心安
代码的世界,简单而又直接

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

说明:文件名格式及效果如下:

  

 

posted on 2022-01-26 10:05  逐梦の心安  阅读(70)  评论(0编辑  收藏  举报