ajMoveFile function
Description
The ajMoveFile function moves a file from one location to another.
Syntax
ajMoveFile(source_file_path, destination_file_path, [overwrite], [run_condition],[run_by_function_point_only])
Argument Name | Argument Type | Description |
---|---|---|
source_file_path (required) | String | The path of the file to be moved. Both the forward-slash (/) and backslash (\) are supported as the folder separator. |
destination_file_path (required) | String | The destination folder path or file path where the file will be moved to. If it is a folder path, then the path needs to end with a slash. Both the forward-slash (/) and backslash (\) are supported as the folder separator. |
overwrite (optional) | Boolean | Defines whether the file at the destination file path should be overridden if it already exists. TRUE - Override the file at the destination file path with the file at the source file path. FALSE - Return a #VALUE! error. The default is FALSE. |
run_condition (optional) | Boolean | The function will run when the value is TRUE. Otherwise will not run. The default value is TRUE. |
run_by_function_point_only (optional) | Boolean | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Preview Function Point. If it equals TRUE, the function can be executed with Preview Function Point (AlchemyJ ribbon \ Preview Function Point) only. The default value is TRUE. |
The function will return:
1) Return Value: TRUE, #VALUE!
2) Return Type: Single Value
Example
Example 1
=ajMoveFile("c:\source.txt", "c:\new_folder\")
If the source file path and destination folder path exist, the function returns TRUE. The file will be moved to c:\new_folder
Example 2
=ajMoveFile("c:\source.txt", "c:\new_folder\target.txt")
If the source file path and destination folder path exist, the function returns TRUE. The file will be moved to c:\new_folder and the file will be renamed to target.txt
Example 3
=ajMoveFile("c:\no_such_file.txt", "c:\new_folder\")
If the source file does not exist, the function willl return #Value.
Click here to download the use case workbooks for further reference.
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will raise error for below scenario(s).
Error Scenario |
---|
Invalid Source File Path. |
Invalid Destination File Path. |
Cannot overwrite the destination file. |
No authority to operate the file. |