FSO reads Chinese files according to the number in Chinese to sort

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

These days to help customers do an automatic upload data program, so that the last found will not be sorted by name, all have to study why, all right, just to paste the data.

The directory data is as follows:

  

Picture 1

Above is the data in a customer's directory. Of course he has a lot. These are not in the scope of our research.

That's just the procedure.

<%

dir = "Shipin"

Set fso = CreateObject ("Scripting.") FileSystemObject ")" Create a File object

Set f = fso. GetFolder (server. MapPath (dir)) ' Read folder

Set FF =f.files ' fetch file name

For each F1 in FF ' Loop directory

Filename=f1.name ' Get file name

Response.Write (FileName)

Next

%>

So that you can read the file name of this directory, of course, everyone will be

The problem is that he came backwards by default. Then we're going to change the way he sort it. Unlike PHP PHP, there are special functions to solve, such as Ksort Natsort

So how do we change him? A way of thinking about it. Take the name of the file and filter out the Chinese, and then use the loop to determine the size of each array to change, of course, this efficiency will be lower. But there is no way. Can only let him run slowly ah, if everyone has a good way to remember to share, the code is as follows:

<%

' Fetch file name array function

function regexptestsp (STR,PAT)

Dim R, Match, matches

Set r = New RegExp

R.pattern = Pat

R.ignorecase = False

R.global = True

Set matches = R.execute (str)

For the Match in matches

Retstr = retstr & Match.value

Next

REGEXPTESTSP = Retstr

End Function

pat= "[\d]+"

' Sort function

Function Sort1 (Input)

Dim OutPut

' Dim input

Dim I

I=0

Dat=split (Input, ",")

For k=0 to Ubound (Dat)

For i=0 to UBound (Dat)-1

If Int (regexptestsp (Dat (i+1), Pat))

Output=dat (i)

Dat (i) =dat (i+1)

Dat (i+1) =output

End If

Next

Next

'

For each outPut in Dat

Response.Write output& "
"

Next

End Function

dir = "Shipin"

Set fso = CreateObject ("Scripting.") FileSystemObject ")" Create a File object

Set f = fso. GetFolder (server. MapPath (dir)) ' Read folder

Set FF =f.files

For each F1 in FF ' Loop directory

filename=filename&f1.name& ","

Next

' Response. Write (filename)

Sort1 (filename)

%>

That's it! This program is used in a larger program. Reprint please famous http://www.002t.cn/yingxiaoyuwangluo/724.html soft brand design (small dai) Ningbo Network Company

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.