Script - Recursive character renaming

Renames a character in all folders or documents from some initial path.

// Recursive renaming & to -
import com.openkm.api.*;
import com.openkm.bean.*;
 
void findNodePathHelper(String path) {
    for (Folder fld : OKMFolder.getInstance().getChilds(null,path)) {
        // print(fld.getPath().substring(fld.getPath().lastIndexOf("/")).replaceAll("&", "-"));
        if (fld.getPath().contains("&")) {
String newName = fld.getPath().substring(fld.getPath().lastIndexOf("/")).replaceAll("&", "-");             OKMFolder.getInstance().rename(null, fld.getPath(), newName);         }
        for (Document doc : OKMDocument.getInstance().getChilds(null, fld.getPath())) {             // print(doc.getPath().substring(doc.getPath().lastIndexOf("/")).replaceAll("&", "-"));
            if (doc.getPath().contains("&")) {
String newName = doc.getPath().substring(doc.getPath().lastIndexOf("/")).replaceAll("&", "-");                 OKMDocument.getInstance().rename(null, doc.getPath(), newName);             }         }
        findNodePathHelper(fld.getPath());     } } findNodePathHelper("/okm:root");