• Bulk Export Folders

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #43611  by kennymac
 
I found the following export example below. However, I do not even know where to begin in setting this up. Also I am not familiar with this language "Permisos de circulación". What I am trying to do is export all documents as PDF in a single folder will be fine. Any help you can provide is greatly appreciated. OpenKM Version is 6.4.24(build: 27101).
Code: Select all
import java.io.File;
import java.io.FileOutputStream;
import java.io.StringWriter;
import com.openkm.util.FileUtils;
import com.openkm.util.impexp.RepositoryExporter;
import com.openkm.util.impexp.TextInfoDecorator;
import com.openkm.util.ArchiveUtils;
import org.apache.commons.io.IOUtils;
 
// Destination 
File file = new File("/home/openkm/import/folderExport.zip");
// OpenKM folder contents to be exported
String fldPath = "/okm:root/Permisos de circulación/import";
 
FileOutputStream os = new FileOutputStream(file);
StringWriter out = new StringWriter();
File tmp = FileUtils.createTempDir();
RepositoryExporter.exportDocuments(null, fldPath, tmp, false, false, out, new TextInfoDecorator(fldPath));
ArchiveUtils.createZip(tmp, "import", os);
org.apache.commons.io.FileUtils.deleteDirectory(tmp);
IOUtils.closeQuietly(out);
os.flush();
os.close();
 #43616  by jllort
 
The previous script, use internal repository exporter tool. That will export folders and sub folders with documents into. Seems this is not what you wish, please explain with more detail your problem ( you want doing daily export, based on what ? new documents, documents updated last day, only from some specific folders, export to file system, overwrite existing exported ones, etc... ? explain the problem you are trying to solve and probably we can give you some clues about how doing it ).

If you are a user of professional version 6.4.24 you should use the OpenKM customer website for support. If you ignore how use it, please as for them at the contact website form https://www.openkm.com/en/contact.html
 #43696  by kennymac
 
I apologize for my delayed response, I am trying to export all documents into there folders as a pdf. So I can move away from openkm. It does not work for our needs anymore. I do have the commercial setup but the lic lapsed. If you can help it is greatly appreciated, however I might just pay for them to help on this last case.
 #43711  by jllort
 
You do not want to merge all PDF is a single PDF no ? only collect all documents into the repository and export into a single server folder no ?

For it must iterate across the repository ( try understanding what it does this scripts https://docs.openkm.com/kcenter/view/ok ... rsal-.html ) and then with OKMDocument API you can export documents https://docs.openkm.com/apidoc/com/okm/ ... ument.html ( must consider two methods getChildren and getContent ). Not much else.
 #43714  by kennymac
 
I need to keep the folders/subfolders hierarchy. The different types of documents I have cannot be merged or it will be useless for me.
 #43718  by jllort
 
Basically with what I provided before you can doing it. It's a simply folders recursive traversal and documents. For each object you must create a folder or write a document in your file system. Except the two openkm methods you will need for getting folders and documents the JAVA code will be exactly as you copy from file system origin to file system destination folders.
 #43739  by kennymac
 
Forgive me for sounding completely ignorant, I am :oops: . Is this a server ran script with a .sh extension or am I a running this through the reports area in web gui? I have created a .sh script located here https://docs.openkm.com/kcenter/view/ok ... rsal-.html and receive multiple errors.
Code: Select all
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.openkm.api.*;
import com.openkm.bean.*;

Logger log = LoggerFactory.getLogger("com.openkm.scripting");
int MAX_DEPTH = Integer.MAX_VALUE;

void nodeTask(String path, int depth) throws Exception {
        for (Document doc : OKMDocument.getInstance().getChildren(null, path)) {
                log.info("Document: {}", doc.getPath());
        }

        for (Folder fld : OKMFolder.getInstance().getChildren(null, path)) {
                log.info("Folder: {}", fld.getPath());

                if (depth < MAX_DEPTH) {
                        nodeTask(fld.getPath(), depth + 1);
                }
        }
}

log.info("**** Process BEGIN ****");
nodeTask("/okm:root", 0);
log.info("**** Process END ****");
import.im6: unable to open X server `' @ error/import.c/ImportImageCommand/368.
import.im6: unable to open X server `' @ error/import.c/ImportImageCommand/368.
import.im6: unable to open X server `' @ error/import.c/ImportImageCommand/368.
import.im6: unable to open X server `' @ error/import.c/ImportImageCommand/368.
./export.sh: line 6: syntax error near unexpected token `('
./export.sh: line 6: `Logger log = LoggerFactory.getLogger("com.openkm.scripting");'
 #43746  by jllort
 
Script execution : Go to Administration > Scripting and paste there the code.

However for more complete solution I suggest create a jar file ( https://docs.openkm.com/kcenter/view/ok ... lipse.html ) you will get best control of the code rather script, where you can have some mistake and you'll only detect while executing. For example in your case might be interesting a crontab job https://docs.openkm.com/kcenter/view/ok ... b-job.html

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.