How to tag related to a specific group

I want to tag files in an indexed folder with a Smart Rule.

The tag should be a folder name but neither the file’s parent folder nor the top-most folder/group (which both easily could be addressed by a Smart Rule placeholder). Something in between, the grandgrandgrandparent folder, so to speak. The level of that folder is always the same.

Would a script have to use the path, chop it up and locate the correct folder? Or is it actually possible to use code containing the parent of the parent of the record?

How does the hierarchy actually look like and which tag would be added?

I am taking notes on the Mac with Curiota. Sadly, Curiota has no tags. I do use hashtags and convert them when importing them into DEVONthink but for much used tags I like to take Curiota’s collections instead.

Each collection is a sub-folder of the “collections” folder (located in the “Curiota” folder) and has a sub-folder “(Notes)” for, guess what, notes and a sub-folder “(Files)” for the rest. As if that wasn’t enough when writing a note Curiota generates a year sub-folder and to that a month sub-folder. So it looks like this:

Curiota Basement

The folders that give the collections their names are the ones in curly brackets, four levels above the note or file. These folder names, stripped from their brackets of course, should become the (additional) tag. With the one exception of the non-collection notes where the folder five levels up is “[Inbox]”. In this case there should be no tag.

Right now I have set up separate Smart Rules for each collection to add the tag. It would be much more comfortable to have just one rule which by script adds the collection tag. Because that script would affect every collection added in the future without any need of setting up a new rule for it.

Thanks for the explanation!

Records can have multiple parents, therefore the syntax would be parent 1 of parent 1 of theRecord

@suavito, did you try the option to use groups as tags?