deno / 1.23.2 / ~ / deno.rename.html /

Deno.rename

Renames (moves) oldpath to newpath. Paths may be files or directories. If newpath already exists and is not a directory, rename() replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

await Deno.rename("old/path", "new/path");

On Unix, this operation does not follow symlinks at either path.

It varies between platforms when the operation throws errors, and if so what they are. It's always an error to rename anything to a non-empty directory.

Requires allow-read and allow-write permission.

function rename( oldpath: string | URL , newpath: string | URL) : Promise<void>;
rename( oldpath: string | URL , newpath: string | URL) : Promise<void>

Parameters

oldpath: string | URL
newpath: string | URL

Return Type

Promise<void>

© 2018–2022 the Deno authors
https://doc.deno.land/deno/stable/~/Deno.rename