renamefile Synchronous

Give a workspace file a new name or location. This is the same operation as movefile; use whichever name reads better in your script.

Syntax
Luau
renamefile(source: string, destination: string) -> ()

Parameters

Function parameters
ParameterTypeDescription
sourcestringWorkspace-relative path of the existing file.
destinationstringWorkspace-relative path it should have afterwards.

Returns

()

No values.

Usage notes

Only files can be renamed, not folders. The call raises if the source is not a file or the destination already exists, so an existing file is never overwritten.

Example

Example
Luau
writefile("draft.txt", "Notes")
renamefile("draft.txt", "notes.txt")
print(isfile("draft.txt"), readfile("notes.txt")) -- false Notes
delfile("notes.txt")