VBS Tutorial: Method-movefolder Method _vbs

Source: Internet
Author: User

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.

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.