Development and Programming
Copying and Renaming file in VBScript
In VBScript, you can use FileSystemObject.CopyFile method to copy and/or rename a file.
Dim fso ' FileSystemObject object.
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("c:\temp\anyfile.html") Then
fso.CopyFile "c:\temp\anyfile.html", "c:\destfolder\newfile.html",true
This method lets us copy one or more files from one location ( the source) to another (destination). Wildcards can be used within the source string, providing it is the last component in the path, to enable the copying of multiple files, but cannot be used in the destination string.
The third parameter is a Boolean. True allows the overwriting of existing files in the destination, providing that the permissions on the destination allow it.
It is recommended that you use the FileExists method when copying or moving a file - if a source file doesn't exist you'll get an error.
© 2019 Digcode.com. All rights reserved.