Qu

rename_file

Builtin index · File I/O

result = rename_file(old, new, [on_exists="error"])

Input: old, new, on_exists · Output: result

What it is

Renames old to new (both Str), generally within the same filesystem. on_exists controls what happens if new already exists: "error" (default) refuses; "overwrite" replaces it; "skip" does nothing and returns false instead of erroring.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = rename_file(old, new, [on_exists="error"])
old StrRenames old to new (both Str), generally within the same filesystem.
new StrRenames old to new (both Str), generally within the same filesystem.
on_exists optional (default "error")on_exists controls what happens if new already exists: "error" (default) refuses.
result —
Returns true if the rename happened, false if skipped. Unlike move_file, does not fall back to copy+delete across drives — a cross-drive rename_file fails with a clear error instead of silently becoming a slower, different operation.

Examples

No documentation example calls this form yet. The File I/O chapter is where one belongs.