The use of CopyFile method in VBS
This article mainly explains "the use of CopyFile method in VBS". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "the use of CopyFile method in VBS" together!
Copy one or more files from one location to another.
object.CopyFile source, destination[, overwrite]
Parameter object
Required. Expected name of FileSystemObject object.
source
Required. A string representing the specified file. When copying one or more files, you can have wildcards in the file name.
destination
Required. A string representing the destination location to which the file is copied from the source. Wildcards are not allowed.
overwrite
Optional. Boolean value indicates whether to overwrite an existing file. If True, files are overwritten; if False, existing files are not overwritten. The default value is True. Note that regardless of the overwrite setting, the CopyFile operation cannot be completed as long as destination is set to the read-only property.
description
Wildcards can only be used in the last component of the path of the source parameter. For example, you can use:
FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"
However, you cannot use:
FileSystemObject.CopyFile "c:\mydocuments\*\R1??? 97.xls", "c:\tempfolder"
If source contains wildcards or destination ends with a path delimiter (\), then destination is assumed to be an existing folder and matching files are copied to that folder. Otherwise, assume destination is the file to be created. In either case, when copying a single file, three things happen.
If destination does not exist, copy source. This is what usually happens.
If destination is an existing file, an error occurs when overwrite is False. Otherwise, copy source overwrites existing files.
If destination is a directory, an error occurs.
If source uses wildcards and there is no matching file, an error occurs. The CopyFile method stops on the first error that occurs. This method does not undo any changes made before the error occurred.
Thank you for reading, the above is the "VBS CopyFile method in the use of" the content of the article, after learning this article, I believe we have a deeper understanding of the use of the VBS CopyFile method, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!