Skip to Content
APIrename

rename

Rename or move a file or directory from oldPath to newPath. Cross-device moves may have platform limits.

Basic usage

import { rename } from '@vooya/fs' await rename('./old.txt', './new.txt') await rename('./dir', './renamed-dir')

Methods

rename(oldPath, newPath)

Async. Returns Promise<void>.

ArgumentTypeDescription
oldPathstringCurrent path.
newPathstringNew path.

renameSync(oldPath, newPath)

Sync. Same arguments; throws on error.

Performance

Single syscall; on par with Node.js. See Benchmarks for single-file behavior.

Notes

  • Overwrite: On many platforms newPath can be overwritten if it exists; behavior is platform-dependent (same as Node.js).
  • Cross-device: Moving across filesystems may not be supported; copy + delete may be required.
  • Known gap: Missing-source and destination errors currently have Node-like messages, but do not expose Node-style code, path, dest, and syscall fields yet.
  • Unsupported Node path inputs: Buffer paths and URL paths are not part of the current Vooya FS rename surface.

Competitor measurements

See the full rename comparison table for Node 22/24, peer libraries, sync/Promise modes, small and batch workloads, execution routes and measurement limits.

Last updated on