MoveFolder method
Move one or more folders from one location to another.
object.MoveFolder source, destination
Parameters
Object
Required option. The name that should be FileSystemObject.
Source
Required option. The path to the folder to move. The source parameter string can only contain wildcard characters in the last part of the path.
Destination
Required option. Specifies a path that indicates that you want to move the folder to that target location. The destination parameter cannot contain wildcard characters.
Description
If source contains wildcard characters or destination ends with a path delimiter (\), assume that destination specifies an existing folder and moves the matching file to that folder. Otherwise, assume that destination is the destination folder to create. In either case, when you move a single folder, the following three situations may occur:
- If destination does not exist, move the folder. This is usually what happens.
- If destination is a file that already exists, an error occurs.
- If the destination is a directory, an error occurs.
If source uses wildcards, but there are no matching folders, an error occurs. The MoveFolder method stops when it encounters the first error that occurs. This method does not undo any changes made before the error occurred.
The following examples illustrate how to use the MoveFolder method:
Sub MoveAFolder(Drivespec) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.MoveFolder Drivespec, "c:\windows\desktop\"End Sub
Important This method allows a folder to be moved between two volumes only if the operating system supports it.