aqFile.Move Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the aqFile.Move method to move one or more files from one location to another.

Declaration

aqFile.Move(PathToExistingFile, PathToNewFile, RenameOnCollision)

PathToExistingFile [in]    Required    String    
PathToNewFile [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:

PathToExistingFile

The name of the file to be moved. Both fully-qualified and relative paths are acceptable. To move several files, use wildcards (* and ?) to specify the mask. Note, that wildcards are only allowed in the file names, not in paths.

PathToNewFile

If PathToExistingFile specifies a single file (not a mask), this parameter can be either the new file path, or the path to the folder where the file will be moved. If PathToExistingFile includes wildcards, this parameter must specify the folder where the matching files will be moved. In either case, if the destination folder does not exist it will be created. Note that if the PathToExistingFile mask does not match any files, the destination folder is not created.

The PathToNewFile parameter accepts both fully-qualified and relative paths. In addition, folder paths must include a trailing backslash (you can add it using the IncludeTrailingBackSlash method).

RenameOnCollision

Specifies the method behavior in case the destination folder already contains a file with the specified name.

If RenameOnCollision is True (which is the default value), the method moves the source file to the Copy of <FileName> file in the destination folder. Otherwise, the method overwrites the destination file.

Result Value

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

If the PathToExistingFile file was not found, the method returns False. But if the PathToExistingFile mask that uses wildcards does not match any files, the method returns True.

Remarks

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

Example

The following statement moves a file to another folder:

JavaScript, JScript

aqFile.Move("C:\\MyFiles\\MyFile.txt", "C:\\TempFolder\\");

Python

aqFile.Move("C:\\MyFiles\\MyFile.txt", "C:\\TempFolder\\")

VBScript

Call aqFile.Move("C:\MyFiles\MyFile.txt", "C:\TempFolder\")

DelphiScript

aqFile.Move('C:\MyFiles\MyFile.txt', 'C:\TempFolder\');

C++Script, C#Script

aqFile["Move"]("C:\\MyFiles\\MyFile.txt", "C:\\TempFolder\\");

The following statement uses the aqFile.Move method to rename a file:

JavaScript, JScript

aqFile.Move("C:\\MyFiles\\MyFile.txt", "C:\\MyFiles\\NewFile.txt");

Python

aqFile.Move("C:\\MyFiles\\MyFile.txt", "C:\\MyFiles\\NewFile.txt")

VBScript

Call aqFile.Move("C:\MyFiles\MyFile.txt", "C:\MyFiles\NewFile.txt")

DelphiScript

aqFile.Move('C:\MyFiles\MyFile.txt', 'C:\MyFiles\NewFile.txt');

C++Script, C#Script

aqFile["Move"]("C:\\MyFiles\\MyFile.txt", "C:\\MyFiles\\NewFile.txt");

The following statement moves all text files from one folder to another:

JavaScript, JScript

aqFile.Move("C:\\MyFiles\\*.txt", "C:\\TempFolder\\");

Python

aqFile.Move("C:\\MyFiles\\*.txt", "C:\\TempFolder\\")

VBScript

Call aqFile.Move("C:\MyFiles\*.txt", "C:\TempFolder\")

DelphiScript

aqFile.Move('C:\MyFiles\*.txt', 'C:\TempFolder\');

C++Script, C#Script

aqFile["Move"]("C:\\MyFiles\\*.txt", "C:\\TempFolder\\");

See Also

Working With Files From Scripts
Create Method
Copy Method
Rename Method
Delete Method
Exists Method
MoveFile Method
Move Method
GetCurrentFolder Method
SetCurrentFolder Method

Highlight search results