Skip to content

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.

ParameterTypeRequirementExplanation
whatstringrequiredPath to a valid, existing file in the local file system
toWherestringrequiredFully qualified destination path (directory and file name) that must not already exist
Return valueExplanation
trueThe file was successfully moved or renamed
falseThe 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.');
}