复制代码
- @echo off
- title code by 523066680 @ cn-dos.net
- if not exist *.jpg (echo,不存在jpg文件&pause>nul&exit)
- setlocal enabledelayedexpansion
- ::判断文件数位数,决定名字前面补0的最大个数.文件数不能多于9位数.
- for %%a in (*.jpg) do set /a a+=1
- set "a=%a%987654321" & set "o=0000000000"
- set /a k=0
- ::避免重命名同名冲突
- ren *jpg *.jpg#
- for /f "tokens=*" %%a in ('dir *.jpg# /b') do (
- set /a k+=1
- set name=%o%!k!
- ren "%%a" "0!name:~-%a:~9,1%!.jpg"
- echo,0!name:~-%a:~9,1%!
- )
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |