VBScript » FileSystemObject » CopyFolder

Version: 2.0

object.CopyFolder source, destination [, overwrite]
Receives the location of one or more folders to be copied.
Receives the location to where one or more folders in source will be copied.
The overwrite parameter is a Boolean. True allows the overwriting of existing files in the destination, providing that the permissions on the destination allow it ( if the destination is set as read-only, the CopyFolder method will fail). An overwrite setting of False prevents existing files in the destination from being overwritten.

Copies one or more folders and all contents, including files and subfolders, from one location to another.

This method lets us copy one or more folders, and all contents, 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. Note that if the source does contain wildcards, it is automatically assumed that the destination is an existing folder and any matching folders are copied to it.

It is recommended that you use the FolderExists method when copying or moving a folder - if a source folder doesn't exist you'll get an error.


dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FolderExists("c:\sourcefolder\website") Then
filesys.CopyFolder "c:\sourcefolder\website", "c:\destfolder\"
End If