本帖最后由 回家路上 于 2015-9-27 09:48 编辑
pcl已经用了JScript了,我就用批处理试了试O(∩_∩)O!- @echo off & setlocal enabledelayedexpansion
- ::文件所放文件夹,测试是当前路径的tmp文件夹自行修改
- for /f "delims=" %%i in ('dir /b /a-d^|findstr /v "%~nx0"') do (
- set file=%%i& set identify=
- set filename=%%~ni
- call :parse !filename! identify chinese
- echo;%%i --》 !identify!!chinese!%%~xi
- )
- pause & exit /b
-
- :parse [string] [identify] [chinese]
- set str=%~1& set ch=& set num=& set sy=& set result=& set c=& set end=
- :lp
- set isC=& set isN=& set isS=
- if "%str:~,1%" geq "a" set /a isC+=1
- if "%str:~,1%" leq "Z" set /a isC+=1
- if "%isC%"=="2" (
- if not defined end (
- if not defined sy (
- if defined num (
- if !num! geq 3 (
- set end=1
- ) else set ch=& set num=& set sy=& set result=
- ) else (
- set result=!result!%str:~,1%
- set /a ch+=1
- )
- ) else set num=& set sy=& set ch=1& set result=%str:~,1%
- )
- ) else (
- if %str:~,1% geq 0 set /a isN+=1
- if %str:~,1% leq 9 set /a isN+=1
- if "!isN!"=="2" (
- if not defined end if defined ch (
- if !ch! geq 3 (
- set result=!result!%str:~,1%
- set /a num+=1
- ) else set ch=& set num=& set sy=& set result=
- )
- ) else (
- if defined num if !num! geq 3 set end=1
- if "%str:~,1%"=="-" set isS=1
- if "%str:~,1%"=="_" set isS=1
- if "%str:~,1%"==" " set isS=1
- if defined isS (
- if not defined end if not defined sy (
- if defined ch (
- set result=!result!%str:~,1%
- set sy=1
- )
- )
- ) else set c=!c!%str:~,1%
- )
- )
- if "%str:~1,1%" neq "" (set str=%str:~1%& goto :lp)
- if !num! geq 3 set %~2=!result!& set %~3=!c!
- goto :eof
复制代码
|