以前写过一个类似的,修改一下为文件名中第一个汉字- @echo off
- for /f "delims=" %%i in ('dir /b /a-d ^|find /v "%~nx0"') do (
- set "name=%%~nxi"
- setlocal enabledelayedexpansion
- call :1 "!name!"
- if defined hanzi (
- for /f "tokens=1" %%a in ('echo !hanzi! ^| pin.exe -p -d3" "') do (
- ren "!name!" "%%a!name!"
- )
- )
- endlocal
- )
- pause
- exit
-
- :1
- set "str=%~1"
- for /l %%l in (0,1,260) do (
- set "hanzi=!str:~%%l,1!"
- if "!hanzi!" neq "" (
- if /i "!hanzi!" gtr "z" (
- exit /b
- )
- ) else exit /b
- )
复制代码
|