Rename
[<Interface>]
type Rename =
abstract member Invoke (oldPath: PathLike, newPath: PathLike, callback: NoParamCallback) : unit
abstract member __promisify__ (oldPath: PathLike, newPath: PathLike) : Promise<unit>| Assembly | Xantham.Fable.Node |
Methods
abstract member Invoke (oldPath: PathLike, newPath: PathLike, callback: NoParamCallback) : unit
abstract member Invoke (oldPath: PathLike, newPath: PathLike, callback: NoParamCallback) : unitAsynchronously rename file at oldPath to the pathname provided as newPath. In the case that newPath already exists, it will be overwritten. If there is a directory at newPath, an error will be raised instead. No arguments other than a possible exception are given to the completion callback.
See also: rename(2).
import { rename } from 'node:fs';
rename('oldFile.txt', 'newFile.txt', (err) => {
if (err) throw err;
console.log('Rename complete!');
});
@since v0.0.2
abstract member __promisify__ (oldPath: PathLike, newPath: PathLike) : Promise<unit>
abstract member __promisify__ (oldPath: PathLike, newPath: PathLike) : Promise<unit>Asynchronous rename(2) - Change the name or location of a file or directory.
| Parameter | |
|---|---|
oldPath | A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. |
newPath | A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. |