VBS Tutorial: method-MoveFolder Method

Source: Internet
Author: User

MoveFolder Method

Move one or more folders from one location to another.

object.MoveFolder source, destination

Parameters

Object

Required. The name of FileSystemObject.

Source

Required. The path of the folder to be moved.SourceThe parameter string can only contain wildcards in the last component of the path.

Destination

Required. Specifies the path to move the folder to the target location.DestinationParameters cannot contain wildcards.

Description

IfSourceContains wildcards orDestinationEnd with path separator (\), it is assumedDestinationSpecify an existing folder to move matching files to the folder. Otherwise, assumeDestinationIs the target folder to be created. In either case, when moving a single folder, the following three situations may occur:

  • IfDestinationIf the folder does not exist, move the folder. This is usually the case.
  • IfDestinationIf it is an existing file, an error occurs.
  • IfDestinationIs a directory, an error occurs.

IfSourceIf a wildcard is used but the folder does not match, an error occurs.MoveFolderMethod stops when the first error occurs. This method does not cancel any changes made before the error occurs.

The following example illustrates how to useMoveFolderMethod:

Sub MoveAFolder(Drivespec)  Dim fso  Set fso = CreateObject("Scripting.FileSystemObject")  fso.MoveFolder Drivespec, "c:\windows\desktop\"End Sub

Key PointsThis method allows moving folders between two volumes only when supported by the operating system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.