O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

FileSystemObject.CopyFolder Method

Syntax

                  oFileSysObj
                  .CopyFolder Source, Destination [, OverwriteFiles]
oFileSysObj

Use: Required

Data Type: FileSystemObject object

A FileSystemObject object.

Source

Use: Required

Data Type: String

The path and name of the folder to be copied from.

Destination

Use: Required

Data Type: String

The path for the folder where the copy is to be made.

OverwriteFiles

Use: Optional

Data Type: Boolean

Flag indicating whether existing files are to be overwritten (True) or not (False). Its default value is True; files of the same name will be overwritten if they already exist in Destination.

Description

Copies the contents of one or more folders, including their subfolders, to another location.

Rules at a Glance

  • Source must 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 in Source only for the last component.

  • Wildcard characters can’t be used in Destination.

  • All subfolders and files contained within the source folder are copied to Destination unless disallowed by the wildcard characters. That is, the CopyFolder method is recursive.

  • If Destination ends with a path separator or Source ends with a wildcard, CopyFolder assumes that the folder stated in Source exists in Destination or should otherwise be created. For example, given the following folder structure:

    C:\
       Rootone
          SubFolder1
          SubFolder2
       RootTwo

    The code FileSys.CopyFolder "c:\Rootone\*", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required