Path.renameSync() method
pathlib-ts > Path > renameSync
Path.renameSync() method
Section titled “Path.renameSync() method”Rename the file or directory to a new target synchronously.
Signature:
renameSync(target: PathLike): Path;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
target |
Destination path or string. |
Returns:
A Path representing the destination.
Remarks
Section titled “Remarks”Mirrors Path.rename() but executes synchronously.
Example
Section titled “Example”Rotating log files synchronously
import { Path } from "pathlib-ts";
const current = new Path("./logs/app.log");current.renameSync("./logs/app.log.1");