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

Folder.Move Method

Syntax

                  oFolderObj
                  .Move destination
oFolderObj

Use: Required

Data Type: Folder object

A Folder object.

destination

Use: Required

Data Type: String

The path to the location where the folder or folders are to be moved.

Description

Moves a folder structure from one location to another.

Rules at a Glance

  • Wildcard characters can’t be used in destination.

  • If any of the files within the folder being moved are open, an error is generated.

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

  • destination can be either an absolute or a relative path.

Programming Tips and Gotchas

  • If a fatal system error (like a power failure) occurs during the execution of this method, the worst that can happen is that the folder is copied to the destination but not removed from the source. There are no rollback capabilities built into the Folder.Move method; since, the copy part of this two-stage process is executed first, the folder can’t be lost.

  • If an error occurs in the middle of a move operation, the operation is terminated, and the remaining files and folders in the folder aren’t moved.

  • If a folder or a file by the same name already exists in destination, the method generates runtime error 58, “File already exists.” To prevent this, you can use the FileSystemObject’s FolderExists and GetAbsolutePath methods prior to calling the Move method.

  • Unlike the FileSystemObject’s MoveFolder ...

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