本帖最后由 happy886rr 于 2017-6-23 17:38 编辑
凑个热闹- @echo off
- REM 开启变量延迟
- setlocal enabledelayedexpansion
-
- REM 构建基表
- set "hSTRING=零一二三四五六七八九"
-
- REM 构建0~99的汉字数字转换表
- for /l %%a in (0,1,9) do (
- for /l %%b in (0,1,9) do (
- if %%b equ 0 (
- set "____!hSTRING:~%%a,1!十=%%a0"
- ) else if %%a equ 0 (
- set "____!hSTRING:~%%b,1!=0%%b"
- ) else if %%a equ 1 (
- set "____十!hSTRING:~%%b,1!=1%%b"
- ) else if %%a gtr 1 (
- set "____!hSTRING:~%%a,1!十!hSTRING:~%%b,1!=%%a%%b"
- )
- )
- )
-
- REM 遍历子目录
- for /r %%a in (*.avi) do (
-
- REM 获取章节
- for /f "tokens=1,2,3* delims=第章节" %%A in ("%%~nxa") do (
-
- REM 将章节转化为数码
- set "chapterNUM=!____%%A!"
- set "sectionNUM=!____%%C!"
-
- REM 真的纯数字直接凑齐两位
- if not defined chapterNUM (
- if "%%A"=="十" (
- set/a "chapterNUM=10"
- ) else (
- set/a "chapterNUM=100+%%A"
- )
- )
- if not defined sectionNUM (
- if "%%C"=="十" (
- set/a "sectionNUM=10"
- ) else (
- set/a "sectionNUM=100+%%C"
- )
- )
-
- echo 正在重命名... "%%~nxa"
- ren "%%a" "第!chapterNUM:~-2!章%%B第!sectionNUM:~-2!节%%D"
- )
- )
-
- REM 更名完毕
- pause
复制代码
|