<?xml version="1.0" encoding="UTF-8"?>
<rename_preset case="none" group="转换" ignoreext="yes" script="yes" type="normal" version="13">
	<from>*</from>
	<to>*</to>
	<script>@script vbscript
&apos; 中文数字转阿拉伯数字-WSQL（中文改数字）
&apos; 将中文读法改成阿拉伯数字，如一百二十三改成123，四十五改成45
&apos; 作者：WSQL, @laoqiuqiu, @Chaoses-Ib
&apos; 版本：220620.2
&apos; 主页：https://github.com/Chaoses-Ib/IbDOpusScripts
Function OnGetCustomFields(ByRef getFieldData)
    &apos;@Chaoses-Ib
    getFieldData.Fields.onlyFirstNum = True
    getFieldData.field_labels(&quot;onlyFirstNum&quot;) = &quot;只转换第一段数字&quot;
End Function
Function OnGetNewName(ByRef getNewNameData)
    Set item = getNewNameData.Item
    newName = item.name_stem
    &apos;正则表达式判断是不是中文读法，不够严谨
    Dim reg
    Set reg = CreateObject(&quot;vbscript.regexp&quot;)
    reg.Pattern = &quot;[一二三四五六七八九十百千万零]{1,}&quot; &apos;正则表达式
    reg.Global = not getNewNameData.custom.onlyFirstNum
    
    Set matches = reg.Execute(newName)
    For Each match In matches
        newName = Replace(newName, match.Value, ConverToDigit(match.Value))
    Next
    OnGetNewName = newName &amp; item.ext
End Function
&apos;将单个文字转换成数字
Function ToDigit(cn)
    Number = 0
    Select Case cn
    Case &quot;壹&quot;, &quot;一&quot;
        Number = 1
    Case &quot;两&quot;, &quot;贰&quot;, &quot;二&quot;
        Number = 2
    Case &quot;叁&quot;, &quot;三&quot;
        Number = 3
    Case &quot;肆&quot;, &quot;四&quot;
        Number = 4
    Case &quot;伍&quot;, &quot;五&quot;
        Number = 5
    Case &quot;陆&quot;, &quot;六&quot;
        Number = 6
    Case &quot;柒&quot;, &quot;七&quot;
        Number = 7
    Case &quot;捌&quot;, &quot;八&quot;
        Number = 8
    Case &quot;玖&quot;, &quot;九&quot;
        Number = 9
    Case &quot;拾&quot;, &quot;十&quot;
        Number = 10
    Case &quot;佰&quot;, &quot;百&quot;
        Number = 100
    Case &quot;仟&quot;, &quot;千&quot;
        Number = 1000
    Case &quot;萬&quot;
    Case &quot;万&quot;
        Number = 10000
    Case &quot;零&quot;
    Case Else
        Number = 0
    End Select
    ToDigit = Number
End Function
&apos;转成成阿拉伯数字
Function ConverToDigit(cnNumber)
    result = 0
    temp = 0
    cnNumber = FixChs(cnNumber)
    For c = 1 To len(cnNumber)
        temp2 = Mid(cnNumber, c, 1)
        temp1 = ToDigit(temp2)
        If temp1 = 10000 Then
            result = result + temp
            result = result * 10000
            temp = 0
        ElseIf temp1 &gt; 9 Then
            If temp1 = 10 And temp = 0 Then
                temp = 1
            End If
            result = result + temp * temp1
            temp = 0
        Else
            temp = temp1
        End If
    Next
    result = result + temp
    ConverToDigit = result
End Function
&apos;修正二百五，三万三的情况
&apos;@laoqiuqiu
Function FixChs(cnNumber)
    Dim LU, SLU
    LU = ToDigit(Right(cnNumber,1))
    SLU = ToDigit(Left(Right(cnNumber,2),1))
    FixChs = cnNumber
    If (SLU &gt; 10) And (LU &lt; 10) Then
        Select Case SLU
            Case 100       : FixChs = cnNumber &amp; &quot;十&quot;
            Case 1000      : FixChs = cnNumber &amp; &quot;百&quot;
            Case 10000     : FixChs = cnNumber &amp; &quot;千&quot;
            Case 100000000 : FixChs = cnNumber &amp; &quot;千万&quot;
        End Select
    End If
End Function</script>
</rename_preset>
