Get the App
SLTechnology News&Howtos  ›  Development  › 

The use of MoveFolder method under VBS

Shulou Source: shulou.com Published: 2022-06-03 19:38:58 11月12日 Update

This article introduces the relevant knowledge of "the use of MoveFolder method under VBS". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Move one or more folders from one location to another.

Object.MoveFolder source, destination

Parameter object

Required. Should be the name of FileSystemObject.

Source

Required. The path to the folder to move. The source parameter string can only contain wildcards in the last part of the path.

Destination

Required. Specify a path that indicates that you want to move the folder to the target location. The destination parameter cannot contain wildcards.

Description

If source contains wildcards or destination ends with a path separator (\), it is assumed that destination specifies an existing folder and moves matching files to that folder. Otherwise, assume that destination is the target folder to create. In either case, when you move a single folder, the following three situations can occur:

If destination does not exist, move the folder. This is what usually happens.

If destination is a file that already exists, an error occurs.

If destination is a directory, an error occurs.

If source uses wildcards but does not match a folder, an error occurs. The MoveFolder method stops when the first error is encountered. This method does not undo any changes made before the error occurred.

The following example illustrates how to use the MoveFolder method:

Sub MoveAFolder (Drivespec) Dim fso Set fso = CreateObject ("Scripting.FileSystemObject") fso.MoveFolder Drivespec, "c:\ windows\ desktop\" End Sub key points this method allows folders to be moved between two volumes only if the operating system supports it.

This is the end of the content of "the use of MoveFolder method under VBS". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: File folder move method error situation path wildcard location parameter content more goal knowledge utility achievement next operating system between two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft Shulou Tech Info NVidia Huawei