Update a lots of files with their history automatically

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.
Post Reply
mamad
Expert Boarder
Expert Boarder
Posts: 112
Joined: Mon Jun 25, 2018 5:13 am

Update a lots of files with their history automatically

Post by mamad » Thu May 23, 2019 7:30 am

hi guys,
Consider the case i have a lots of files (1000 for example) and also have their history (other versions)
How can i upload all of these files with their history ?
I try import/export but it only imports one version of each file and wont add their history !
Is there any way to do this operation automatically (maybe with some scripts ) ??

saulhidalgo
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: Sat Nov 05, 2011 1:06 pm

Re: Update a lots of files with their history automatically

Post by saulhidalgo » Thu May 23, 2019 7:21 pm

Good afternoon.

Yes, It can be done automatically. I would suggest to do a custom script using the API that uploads the files checking if the document already exists, to upload the new version of it.

Please, take a look at the API Description section, in your case, you would be interested on the entry OKMDocument and maybe OKMDocumentService.

You can also contact me in case you need any advice or guide to do it.

Mail: saulhidalgoaular@gmail.com.
Skype: saulhidalgoaular@outlook.com
Phone: +58 426 517 94 59.

Best Regards.
Saul Hidalgo.

mamad
Expert Boarder
Expert Boarder
Posts: 112
Joined: Mon Jun 25, 2018 5:13 am

Re: Update a lots of files with their history automatically

Post by mamad » Sat May 25, 2019 5:16 am

hi saulhidalgo
thanks for your reply
Does your approach works for cases we have a lots of versions for each document too?
Actually i have a lots of document which every one has a lots of versions.

jllort
Moderator
Moderator
Posts: 10868
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Update a lots of files with their history automatically

Post by jllort » Sat May 25, 2019 8:43 am

Should use an script, upload the oldest file ( create ) and then modify ( checkout, checkin ) with the new versions:

https://docs.openkm.com/kcenter/view/ok ... eateSimple
https://docs.openkm.com/kcenter/view/ok ... l#checkout ( mark for edition )
https://docs.openkm.com/kcenter/view/ok ... ml#checkin ( update )

You can also use the SDK's for java for this kind of iterations or scripting ( crontab task ) from OpenKM side
https://docs.openkm.com/kcenter/view/ok ... pting.html
https://docs.openkm.com/kcenter/view/ok ... ontab.html
https://docs.openkm.com/kcenter/view/ok ... b-job.html

mamad
Expert Boarder
Expert Boarder
Posts: 112
Joined: Mon Jun 25, 2018 5:13 am

Re: Update a lots of files with their history automatically

Post by mamad » Sun Jun 09, 2019 5:49 am

Instead of doing your solutions i found another way and upload all of my files with their histories correctly !
Now i will share my way for other guys who looking for a free way !!!
Its easy
consider your file is "myfile.pdf" and it has two version (1.0 and 2.0).Now export this file with history.If you look at the exported file you will see a structure like this :
myfile.pdf -> its a an empty file
myfile.pdf#v1.0# -> its the version 1.0 of file
myfile.pdf#v2.0# -> its the version 2.0 of file
If you create this structure for every file and Import it back to openkm you will have your file with its history !
So you need to write a simple script to create this structure. these are steps you have to do:
1- First of all you have to Export the whole or maybe a part of your current directory of openkm
Then for each file :
1- locate your files with their histories(other versions) in your directory of files(your hard disk or ...)
2- locate path of the file in the openkm foldering structure
3- create a empty file with the name of your file (for example myfile.pdf)
now for each version of your file :
1- copy that version of file to the directory you founded
2- reaname the file to proper format.for example for version 3.1 of "myfile.pdf",i have to rename it to : "myfile.pdf#v3.1#"
After coping all files to your openkm foldering structure,Import it back to openkm(dont forget to check History option)
This solution works for me 100% !!!

jllort
Moderator
Moderator
Posts: 10868
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Update a lots of files with their history automatically

Post by jllort » Sun Jun 09, 2019 9:22 am

Yes, that should working if you reproduce the same way on how OpenKM exports history you get a way to import. I thought was easily done from code either building this structure, that's why I do not explain this option. Really with the repository export / import format ( based in json -> the okm files ) you can change all the values ( security, owner, metadata, dates ). There's a direct mapping between this format and what you get into the repository.

Post Reply