rename
Renames a file or directory within its parent directory.
Example
ts
import { SF } from "@duplojs/server-utils";
const result = await SF.rename("/tmp/file.txt", "renamed.txt");
// result: E.Success<string> | SF.FileSystemLeft<"rename">
await SF.rename("/tmp/notes.txt", "notes-old.txt");Syntax
typescript
function rename(
path: string,
newName: string
): Promise<FileSystemLeft<"rename"> | E.Success<string>>Parameters
path: path to rename.newName: new name (without path).
Return value
E.Success<string>: the new path when renaming succeeds.FileSystemLeft<"rename">: if renaming fails.
See also
move- Moves a file or directory.
