Page 1 of 1

Automatic tagging based on folder

PostPosted:Fri Jan 17, 2014 11:34 am
by Ben.Hahlen
I have been using OpenKM for a while now and I am really enjoying it.
However, I am trying to improve my usage by adding tags to my documents.
Preferably, this would happen automatically when adding documents to OpenKM, either by upload or by copying it into a WebDAV-mount.
My folder structure is set up as such:
<NAME>
|-<COMPANY>
||-<YEAR>
|||-<FILENAME>

Preferably, the tags on the file would consist of <COMPANY> and <YEAR>.
Is it possible to automate this in some way?
Which path should I take? Scripting? Macro? Workflow?

Thanks in advance :)

Re: Automatic tagging based on folder

PostPosted:Sat Jan 18, 2014 10:21 am
by jllort
Before give you some ideas ( clues ) we need to know the logic behing to identify document type and decide what tags should be added. Before knowing anything I suggest scripting or a combination of metadata and crontab ( metadata to set property group to indicate pending status after document creation or change, and crontab to analytize and autotag the pending documents and change status ).

If you decide to doing it, we'll be pleased to sharing your code example in our wiki documentation at http://wiki.openkm.com/index.php/Utilities . I think your work can be interesting for other users.

Re: Automatic tagging based on folder

PostPosted:Mon Jan 20, 2014 7:46 am
by Ben.Hahlen
Of course I'll share the end-result, I am just looking for some pointers, as I am a bit overwhelmed with all the options available :-)

Let's take this folder structure as an example:
okm:root/Ben/Bank/2013/Correspondence
The file is:
2013-01-02 - Statement.pdf

The tags (/keywords) that I would like to be added are: Bank, 2013, Correspondence
If possible, if it could add "statement" as a keyword as well, that would be awesome, but it might be a bit too complex.

So, basically what you are suggesting so far:
On import of document, metadata should be added, providing a "untagged" status, it will then parse through the directories, adding the keywords, after which it will receive a "tagged" status.
And then a cron-job that triggers this?

Breaking this down (and from what I can find in my Administration Dashboard):
- CronJob
|- AnalyzeTag.bsh
|- AutoTag.bsh
- Metadata
|- Property Groups
||- Tagged/Untagged
- Automation
|- Tagging stuff

Is this the right track?

Re: Automatic tagging based on folder

PostPosted:Wed Jan 22, 2014 3:34 pm
by jllort
if tags are based on folder path, simply can execute script after document creation , splith path / and then add keywords

Re: Automatic tagging based on folder

PostPosted:Wed Jan 22, 2014 4:15 pm
by Ben.Hahlen
Right... Let's see what I can cook up :)

Re: Automatic tagging based on folder

PostPosted:Tue Apr 03, 2018 9:35 pm
by neil_h
Hi

Sorry to bump an old thread, but this is exactly what i want to do, and i cant see the end result on the Utilities page as listed further up this thread. can any one help?

Thanks

Neil

Re: Automatic tagging based on folder

PostPosted:Wed Apr 04, 2018 8:18 am
by lnovoa
Hi!,
can you better specify your case and detail the steps you have taken?

Re: Automatic tagging based on folder

PostPosted:Wed Apr 04, 2018 2:21 pm
by neil_h
Hi

So in essence, i want to achieve the same as the original poster, sorting documents into a folder structure, this is for home use, to electronically store info on mortgage, insurances etc. the folder structure would consist of a descriptive root folder, Year, such as

okm:root, Insurance, 2018, House
or
okm:root, Insurance, 2018, Car

then each folder would have as assigned keyword of the same name "Insurance, 2018, House" as appropriate. I will be imaging documents on my phone and uploading by Webdav to the correct folder structure. I want a Create Document action to add the folders structures tags to the new document to aid searching later on.

Although i have done coding in the past (15 + years ago) it was in Pascal, not in Java or C which appear to be the languages involved (could be wrong). Ive started looking at the automation options and and see i can add a action to a create document event.

I have been reading https://docs.openkm.com/kcenter/view/ok ... ction.html and whilst this has a AddKeyword Class on the page, i dont know where to start..

I have also traced the UUID's through the DB and know it will need a recursive call to process the folder structure for its tags. but again im not sure where to start and nothing ive seen shows where the DB SQL lookups correlate to the automation code.

Does this give enough info

Thanks

Neil