Skip to content

Path.renameSync() method

pathlib-ts > Path > renameSync

Rename the file or directory to a new target synchronously.

Signature:

renameSync(target: PathLike): Path;

Parameter

Type

Description

target

PathLike

Destination path or string.

Returns:

Path

A Path representing the destination.

Mirrors Path.rename() but executes synchronously.

Rotating log files synchronously

import { Path } from "pathlib-ts";
const current = new Path("./logs/app.log");
current.renameSync("./logs/app.log.1");