Name
FileSystemObject.CopyFolder Method
Syntax
oFileSysObj.CopyFolderSource,Destination[,OverwriteFiles]
oFileSysObjUse: Required
Data Type: FileSystemObject object
A FileSystemObject object.
SourceUse: Required
Data Type: String
The path and name of the folder to be copied from.
DestinationUse: Required
Data Type: String
The path for the folder where the copy is to be made.
OverwriteFilesUse: Optional
Data Type: Boolean
Flag indicating whether existing files are to be overwritten (
True) or not (False). Its default value isTrue; files of the same name will be overwritten if they already exist inDestination.
Description
Copies the contents of one or more folders, including their subfolders, to another location.
Rules at a Glance
Sourcemust end with either a wildcard character or no path separator. If it ends with a wildcard character, all matching subfolders and their contents will be copied. Wildcard characters can be used inSourceonly for the last component.Wildcard characters can’t be used in
Destination.All subfolders and files contained within the source folder are copied to
Destinationunless disallowed by the wildcard characters. That is, the CopyFolder method is recursive.If
Destinationends with a path separator orSourceends with a wildcard, CopyFolder assumes that the folder stated inSourceexists inDestinationor should otherwise be created. For example, given the following folder structure:C:\ Rootone SubFolder1 SubFolder2 RootTwoThe code
FileSys.CopyFolder"c:\Rootone\*", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access