rename-file
(rename-file file new-name)
Renames (moves) file to new-name and returns the defaulted new name as a
pathname. new-name is merged with file the way
merge-pathnames merges, so a bare file name keeps the
original directory. Anything that leaves the file where it was signals -- "it
was not there" included, exactly like delete-file.
CL-USER> (rename-file "notes.txt" "notes.bak")
#P"notes.bak"
CL-USER> (rename-file "db/2026.up.sql" "2026.down.sql")
#P"db/2026.down.sql"
Lite deviation: Common Lisp returns (values defaulted-new-name old-truename new-truename) and this returns the defaulted new name only -- the same rule
ensure-directories-exist follows, because a
secondary value would not survive the function boundary on the compiled
backends.
Backend support
All four backends rename for real. Both WASM backends move through the path_rename WASI import (Preview 1 directly, --component through wasi:filesystem's rename-at); "it was not there" signals the same file-error as delete-file everywhere.