Move Method

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

Description

Use the Move method to move the folder, to which the given aqFolderInfo object corresponds, from one location to another. The method can resolve possible name collisions that may occur while copying folders.

Declaration

aqFolderInfoObj.Move(NewPath, RenameOnCollision)

aqFolderInfoObj An expression, variable or parameter that specifies a reference to an aqFolderInfo object
NewPath [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:

NewPath

The path to the destination folder to which the given folder will be moved along with its contents. Both fully-qualified and relative paths are acceptable. This path may or may not include a trailing backslash.

RenameOnCollision

Specifies the method behavior in case the NewPath 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 NewPath folder and moves the source folder’s contents to that subfolder. Otherwise, the method moves the folder contents to the existing destination subfolder replacing the files having the same name.

Result Value

True if the folder was moved successfully, and False otherwise.

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 code below moves the folder from one location to another.

JavaScript, JScript

function MovingFolderExample()
{

  // Specifies the path to the folder
  var sPath = "C:\\MyFiles";
  
  // Specifies a new path to the folder
  var sNewPath = "C:\\Work\\TempFiles\\";
  
  // Moves the specified folder
  aqFileSystem.GetFolderInfo(sPath).Move(sNewPath);
  
}

Python

def MovingFolderExample():
  # Specifies the path to the folder
  sPath = "C:\\MyFiles"
  # Specifies a new path to the folder
  sNewPath = "C:\\Work\\TempFiles\\"
  # Moves the specified folder
  aqFileSystem.GetFolderInfo(sPath).Move(sNewPath)

VBScript

Sub MovingFolderExample

  ' Specifies the path to the folder
  sPath = "C:\MyFiles"
  
  ' Specifies a new path to the folder
  sNewPath = "C:\Work\TempFiles\"
  
  ' Moves the specified folder
  aqFileSystem.GetFolderInfo(sPath).Move(sNewPath)
  
End Sub

DelphiScript

function MovingFolderExample;
var sPath, sNewPath;
begin

  // Specifies the path to the folder
  sPath := 'C:\MyFiles';
  
  // Specifies a new path to the folder
  sNewPath := 'C:\Work\TempFiles\';
  
  // Moves the specified folder
  aqFileSystem.GetFolderInfo(sPath).Move(sNewPath);
  
end;

C++Script, C#Script

function MovingFolderExample()
{

  // Specifies the path to the folder
  var sPath = "C:\\MyFiles";
  
  // Specifies a new path to the folder
  var sNewPath = "C:\\Work\\TempFiles\\";
  
  // Moves the specified folder
  aqFileSystem["GetFolderInfo"]( sPath )["Move"]( sNewPath );
  
}

See Also

Working With Files From Scripts
Copy Method
Rename Method
MoveFolder Method
GetCurrentFolder Method
SetCurrentFolder Method

Highlight search results