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.
Luau
renamefile(source: string, destination: string) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
source | string | Workspace-relative path of the existing file. |
destination | string | Workspace-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
Luau
writefile("draft.txt", "Notes")
renamefile("draft.txt", "notes.txt")
print(isfile("draft.txt"), readfile("notes.txt")) -- false Notes
delfile("notes.txt")