aqFileSystem.MoveFolder Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use the MoveFolder method to move one or more folders, including all of their contents, from one location to another. The method can resolve possible name collisions that may occur while copying folders.

Declaration

aqFileSystem.MoveFolder(Source, Destination, RenameOnCollision)

Source [in]    Required    String    
Destination [in]    Required    String    
RenameOnCollision [in]    Optional    Boolean Default value: True   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Source

The path to the folder to be moved. Both fully-qualified and relative paths are acceptable. This path must not include a trailing backslash (to remove it from the path, you can use the aqFileSystem.ExcludeTrailingBackSlash method).

To copy several folders, use wildcards (* and ?) to specify the mask. Note, that wildcards are only allowed in the last component of the path.

Destination

The path to the destination folder to which the Source folders will be moved along with their contents. Both fully-qualified and relative paths are acceptable. This path may or may not include a trailing backslash. If the destination folder does not exist, it will be created.

Note that if the Source mask does not match any file, the destination folder is not created.

RenameOnCollision

Specifies the method behavior in case the Destination folder already contains a subfolder with the same name as the Source folder. If RenameOnCollision is True (which is the default value), the method creates the Copy of <FolderName> subfolder in the Destination folder and moves the Source’s contents to that subfolder. Otherwise, the method moves the Source folder’s contents to the existing destination subfolder replacing the files having the same name.

Result Value

True if all the specified folders were moved successfully, and False otherwise.

If the Source folder was not found, the method returns False. However, if the Source mask that uses wildcards does not match any folder, the method returns True.

Remarks

If the method fails to move the folder, TestComplete will post an information message to the test log explaining the cause of the failure.

Example

The following statement moves the C:\MyFolder folder to the C:\TempFolder:

JavaScript, JScript

aqFileSystem.MoveFolder("C:\\MyFolder", "C:\\TempFolder");

Python

aqFileSystem.MoveFolder("C:\\MyFolder", "C:\\TempFolder")

VBScript

Call aqFileSystem.MoveFolder("C:\MyFolder", "C:\TempFolder")

DelphiScript

aqFileSystem.MoveFolder('C:\MyFolder', 'C:\TempFolder\');

C++Script, C#Script

aqFileSystem["MoveFolder"]("C:\\MyFolder", "C:\\TempFolder");

The following statement moves all subfolders of C:\MyFolder whose name end with “Project” to C:\TempFolder:

JavaScript, JScript

aqFileSystem.MoveFolder("C:\\MyFolder\\*Project", "C:\\TempFolder");

Python

aqFileSystem.MoveFolder("C:\\MyFolder\\*Project", "C:\\TempFolder")

VBScript

Call aqFileSystem.MoveFolder("C:\MyFolder\*Project", "C:\TempFolder")

DelphiScript

aqFileSystem.MoveFolder('C:\MyFolder\*Project', 'C:\TempFolder');

C++Script, C#Script

aqFileSystem["MoveFolder"]("C:\\MyFolder\\*Project", "C:\\TempFolder");

See Also

Working With Files From Scripts
CopyFolder Method
RenameFolder Method
DeleteFolder Method
Move Method
MoveFile Method
Exists Method
GetCurrentFolder Method
SetCurrentFolder Method

Highlight search results