<?xml version="1.0" encoding="UTF-8"?>
<rename_preset case="none" group="My" ignoreext="yes" preset="11 中文数字转阿拉伯数字(匹配)" script="yes" type="normal" version="13">
	<from>*</from>
	<to>*</to>
	<script>@script vbscript
Option Explicit
Function OnGetNewName(ByRef getNewNameData)
        Dim item, re, s1, s2, i, chr, ss , str, name, ext,  di,  zhang,  lens, jiange
        str = &quot;零一二三四五六七八九十百千&quot;
        Set item = GetNewNameData.item
        name = item.name_stem
        name = replace(name,&quot; &quot;,&quot;&quot;)
        ext = item.Ext
        di = getNewNameData.custom.di
        zhang = getNewNameData.custom.zhang
        lens = Cint(getNewNameData.custom.lens)
        jiange = getNewNameData.custom.jiange
        Set re = New RegExp
        re.Pattern = &quot;^[\s　]*&quot; + di + &quot;([&quot; &amp; str &amp; &quot;〇两廿]+)&quot; + zhang + &quot;(?:节|[\s　]*([^\s　]*))[\s　]*$&quot;
        If Not re.Test(name) Then OnGetNewName = name + ext  : Exit Function
        s1 = re.Execute(name)(0).SubMatches(0)
        s2 = re.Execute(name)(0).SubMatches(1)
        s1 = Replace(s1, &quot;〇&quot;, &quot;零&quot;) : s1 = Replace(s1, &quot;两&quot;, &quot;二&quot;) : s1 = Replace(s1, &quot;廿&quot;, &quot;二十&quot;)
        If Left(s1, 1) = &quot;十&quot; Then s1 = &quot;一&quot; &amp; s1
        For i = 1 to Len(s1)
                chr = Mid(s1, i, 1)
                If InStr(str, chr) &gt; 10 Then
                        ss = ss &amp; &quot;*10^&quot; &amp; (InStr(str, chr)-10) &amp; &quot;+&quot;
                Else
                        ss = ss &amp; (InStr(str, chr)-1)
                End If
        Next
        s1 = Right(&quot;0000&quot; &amp; eval(ss &amp; &quot;+0&quot;), lens)
        
        If s2 &lt;&gt; &quot;&quot; Then s2 = jiange + s2

        OnGetNewName = di + s1 + zhang + s2 + ext                 
End Function
function OnGetCustomFields(ByRef getFieldData)
	getFieldData.fields.di = &quot;第&quot;
	getFieldData.fields.zhang = &quot;章&quot;
	getFieldData.fields.lens = 3
	getFieldData.fields.jiange = &quot; &quot;

	getFieldData.field_labels(&quot;di&quot;) = &quot;第一个匹配字&quot;
	getFieldData.field_labels(&quot;zhang&quot;) = &quot;第二个匹配字&quot;
	getFieldData.field_labels(&quot;lens&quot;) = &quot;编号位数&quot;
	getFieldData.field_labels(&quot;jiange&quot;) = &quot;间隔符号(默认空格)&quot;
End Function
</script>
	<custom>
		<var name="di" type="8">第</var>
		<var name="jiange" type="8"> </var>
		<var name="lens" type="2">3</var>
		<var name="zhang" type="8">章</var>
	</custom>
</rename_preset>
