Getting name of folder using relative path

I’m needing to set some text in an alarm and planning to use the name of the folder using a relative path to the folder names:

path is:
{[.]…}

This just returns me a number, 2 I think, but what I need is the name. I tried to add .name to the path to get the property but this does not work. I’ve looked at what I can find, but cannot seem to find a solution. Am I just not getting it or should I find another solution.

Thanks!

There are likely a few ways to do this, but the relative path will not return a name in the way you are desiring.

For your use-case:

I’m needing to set some text in an alarm and planning to use the name of the folder

You can likely achieve this with the built-in displayPathOrSource property along with the help of some string functions.

For example, consider a tag called “Test Alarm” located within a folder called “Folder”. If an alarm is added to that tag and a binding is placed on the Label property that contains this expression:

split(toStr({displayPathOrSource}), ":")[3, 0]

The resulting Label property will be: “Folder/Test Alarm” , and from there you can use split() again to return just the string “Folder”. The expression would be:

split(split(toStr({displayPathOrSource}), ":")[3, 0], "/")[0,0]

Since the folder name is contained in the source path we can use split() to parse out exactly what we want.