renameFolder(folderPath, newName)
Renames an existing folder without moving it. The folder remains in its current parent directory but receives a new name.
Parameters
folderPathstringrequiredEntire absolute path for folder to rename.
newNamestringrequiredNew name without path.
Returns
true when the folder was renamed.
Throws if the path or the new name is empty, the folder does not exist, the new name is not valid, or another folder in the same parent already has that name. A target that only exists in the app (publish template) the site runs from throws error 110: the app's files are shared by every site on it and can't be changed from a site.
The call runs as the user who published the site, not as the visitor. Check the visitor's own rights with allowModify before you change anything on their behalf. If the publisher does not own the workspace but has the folder shared with them directly, only the publisher's own name (alias) for the shared folder changes — the folder itself keeps its name.
Example
// Renames folder in specified location, folder stays in the same parent folder
docly.renameFolder("ParentFolder/OldFolderName", "NewFolderName");
// Example with error handling
try {
docly.renameFolder("Projects/MyProject", "MyRenamedProject");
console.log("Folder renamed successfully");
} catch (e) {
// Throws if path or name is empty, the folder does not exist, or the name is invalid or taken
console.log("Failed to rename folder: " + e);
}