Script - Purge all users trashes

import com.openkm.api.*;
import com.openkm.core.*;
import com.openkm.bean.*;
import com.openkm.module.db.stuff.*;
 
String token = DbSessionManager.getInstance().getSystemToken();
 
for (Folder trash : OKMFolder.getInstance().getChildren(token, "/okm:trash")) {
    print("Trash: " + trash.getPath() + "<br/>");
 
    for (Folder fld : OKMFolder.getInstance().getChildren(token, trash.getPath())) {
        print("About to delete folder: " + fld.getPath() + "<br/>");
        OKMFolder.getInstance().purge(token, fld.getPath());
    }
 
    for (Document doc : OKMDocument.getInstance().getChildren(token, trash.getPath())) {
        print("About to delete document: " + doc.getPath() + "<br/>");
 
        if (OKMDocument.getInstance().isLocked(token, doc.getPath())) {
            OKMDocument.getInstance().forceUnlock(token, doc.getPath());
        }
 
        OKMDocument.getInstance().purge(token, doc.getPath());
    }
 
    for (Mail mail : OKMMail.getInstance().getChildren(token, trash.getPath())) {
        print("About to delete mail: " + mail.getPath() + "<br/>");
        OKMMail.getInstance().purge(token, mail.getPath());
    }
}