Use the FSO to read the total number of files and modify the file name

Source: Internet
Author: User
Reads the total number of files in the file and modifies the file name as needed.

Reads the total number of files in the file and modifies the file name as needed.

The code is as follows:
<%
On Error Resume Next
Set fso = CreateObject ("Scripting.FileSystemObject")
Set Uploadfolder = fso. GetFolder (Server.MapPath ("img")) ' img For the specified folder
Set allfiles = Uploadfolder. Files
If IsEmpty (request.querystring ("act")) then
I=1
Response. Write "<table width=" "620" "border=" "1" "cellspacing=" "0" "cellpadding=" "5" "align=" "Center" ">"
For each fileitem in Allfiles
sFileName = Fileitem. Name
Response. Write "<tr>"
Response. Write "<td width=" "align=" "Center" ">" &i& "</td>"
Response. Write "<td width=" "450" ">" &sFileName& "</td>"
Response. Write "<td width=" "align=" "Center" "><a href=" "javascript:;" "onclick=" "Javascript:window.open ('? act= Edit&filename= "&sFileName&", ' NewWindow ', ' height=300, width=550, top=250, left=250, Toolbar=no, menubar =no, Scrollbars=no, resizable=no,location=n o, Status=no ') "> Edit text File </a></td>"
Response. Write "</tr>"
I=i+1
Next
Response. Write "</table>"
Response. Write "Total Files:" & (I-1)
End If

If Request ("act") = "Savefilename" Then
Set F=FSO. GetFile (server. MapPath ("img/" &request ("Ofn"))
F.name =request ("Filestr")
Set f=nothing
End If
If Request.QueryString ("act") = "edit" Then
%>
<table align= "Center" border= "1" width= "100%" height= "100%" cellspacing= "0" cellpadding= "3" bordercolor= "#6595d6" >
<form name= "Form1" method= "Post" action= "Act=savefilename&ofn=<%=request" ("filename")%> ">
<tr><th> Edit Text File </th>
</tr>
<tr><td> file Name:
<textarea name= "Filestr" style= "width:98%;height:100%;" ><%=request ("filename")%></textarea></td></tr>
<tr height= "><TD" align= "Center" >
<input type= "Submit" value= "save" ><input type= "button" value= "Close" onclick= "window.close ();" >
</td></tr>
</form>
</table>
<%
End If
%>



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.