MoveFile (move/rename a file)
ts
function MoveFile(what: string, toWhere: string): boolean;Moves or renames the file specified by what to the toWhere destination path in the local file system. Returns true if the operation is successful, or false if it fails.
| Parameter | Type | Requirement | Explanation |
|---|---|---|---|
what | string | required | Path to a valid, existing file in the local file system |
toWhere | string | required | Fully qualified destination path (directory and file name) that must not already exist |
| Return value | Explanation |
|---|---|
true | The file was successfully moved or renamed |
false | The operation failed; the file was not moved or renamed |
NOTE
If a file already exists at the destination path, the operation will fail and return false.
Example
ts
var result = MoveFile('/home/user/data.txt', '/home/user/archive/data.txt');
if (result) {
Log('File moved successfully.');
} else {
Log('File move failed.');
}