Modify file name

Source: Internet
Author: User

Use ASP to modify the file name

For example, if a file already exists and the path is 'd: \ files \ test. asp, I want to change it to new. asp and the path remains unchanged. How should I write it?
As follows:
Set fso = Server. CreateObject ("Scripting. FileSystemObject ")
Set f = fso. GetFile ("d: \ files \ test. asp ")
F. name = "new. asp"
Newname = f. name
Response. write newname is displayed as: new. asp

Another method is as follows:
Set fso = Server. CreateObject ("Scripting. FileSystemObject ")
Fso. movefile "d: \ files \ test. asp", "d: \ files \ new. asp"

========================================================== ==========================================================

Name attribute
Description

Sets or returns the name of the specified file or folder. Read/write attributes.

Syntax

Object. Name [= newname]

The Name attribute has the following parts:

Partial description
Required. It is always the name of a File or Folder object.
Newname is optional. If yes, newname is the new name of the specified object.


Description

The following code illustrates the usage of the Name attribute:

Sub ShowFileaccessInfo (filespec)
Dim fs, f, s
Set fs = CreateObject ("Scripting. FileSystemObject ")
Set f = fs. GetFile (filespec)
S = f. Name & "on Drive" & UCase (f. Drive) & vbCrLf
S = s & "Created:" & f. DateCreated & vbCrLf
S = s & "Last accessed:" & f. DateLastaccessed & vbCrLf
S = s & "Last Modified:" & f. DateLastModified
MsgBox s, 0, "File access Info"
End Sub

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.