Pages Menu
Categories Menu

Posted by on Sep 23, 2013 in Code Snippets | 0 comments

Copy a Folder and all of its Contents

Copy a Folder and all of its Contents

Syntax:  object.CopyFolder SOURCE, DESTINATION[, OVERWRITE]

Parameters:

  • SOURCE – Required. Character string folder specification, which can include wildcard characters, for one or more folders to be copied.
  • DESTINATION –Required. Character string destination where the folder and subfolders from source are to be copied. Wildcard characters are not allowed.
  • OVERWRITE –Optional. Boolean value that indicates if existing folders are to be overwritten. If True, files are overwritten; if False, they are not. The default is True.

Usage:

    Dim objFSO As Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.copyFolder "C:\Path\to\source\folder", "C:\Path\to\destination\folder" true