ReferenceFilesystem

renamefile

Moves a workspace file to a new path.

Syntax

renamefile(from: string, to: string) -> ()
movefile(from: string, to: string) -> ()

Also available as

movefile

Parameters

ParameterTypeDescription
fromstringWorkspace-relative file to move.
tostringWorkspace-relative destination.

Description

The file is written to the destination and then removed from the old path. The destination must not already exist, and writing it follows the same rules as writefile, including the blocked program extensions. If the destination cannot be written the original file stays where it was.

Example

writefile("old-name.txt", "hello")
renamefile("old-name.txt", "new-name.txt")
print(isfile("old-name.txt"), readfile("new-name.txt"))
delfile("new-name.txt")

These are Game executor contracts. Check build requirements and session lifetimes before using them.