Page 1 of 1

Update a lots of files with their history automatically

PostPosted:Thu May 23, 2019 7:30 am
by mamad
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 ) ??

Re: Update a lots of files with their history automatically

PostPosted:Thu May 23, 2019 7:21 pm
by saulhidalgo
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.

Re: Update a lots of files with their history automatically

PostPosted:Sat May 25, 2019 5:16 am
by mamad
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.

Re: Update a lots of files with their history automatically

PostPosted:Sat May 25, 2019 8:43 am
by jllort
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

Re: Update a lots of files with their history automatically

PostPosted:Sun Jun 09, 2019 5:49 am
by mamad
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% !!!

Re: Update a lots of files with their history automatically

PostPosted:Sun Jun 09, 2019 9:22 am
by jllort
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.