# Get name from folder in Tag Browser

**URL:** <https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601>\
**Category:** Ignition\
**Created:** [April 29, 2016, 12:46pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601 "2016-04-29T12:46:16Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [April 29, 2016, 12:46pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/1 "2016-04-29T12:46:16Z")

</div>

Hi everyone,

I have a some naming conventions associated with how I built my folder hierarchy in the tag browser and I was wondering if you could get to folder names through expressions.

Hopefully the attached pic helps show what I want to do. In it, I have a data type called Test\_Machine. Instead of giving that datatype Line\_ID and Machine\_ID parameters that I have to type in myself for every instance, I want them to have expression properties whose values come from the number at the end of the parent and parent’s parent folder. This way, simply creating a data type in a particular location would be enough for it to describe itself. So if you read down, the current null values would be:

1  
1

1  
2

1  
3

Thanks in advance,  
Steve

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [April 29, 2016, 4:26pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/2 "2016-04-29T16:26:46Z")

</div>

This thread should get you started

[inductiveautomation.com/forum/v … lit=+parse](https://inductiveautomation.com/forum/viewtopic.php?f=25&t=15097&hilit=+parse)

---

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [April 29, 2016, 6:00pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/3 "2016-04-29T18:00:55Z")

</div>

Hi,

Thanks for the reply. I saw that thread when cruising the forum before posting and unless I missed something (quite possible!) I don’t think it’s what I’m after.

You have a tag path hard-coded and then correctly state there are a million ways to parse strings. But how could I get that string dynamically based on where my data type instance is? I want an expression tag in my Test\_Machine data type that would display the values “Test\_Machine\_1”, “Test\_Line\_1”, “Test\_Machine\_2”, “Test\_Line\_1”, etc. but don’t know if the text from folders is accessible.

If it’s possible I’d then need to use the Expression language and not Python. I don’t think that would be a problem with either Strings expression functions or runScript and will cross that bridge if I get to it.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [April 29, 2016, 11:07pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/4 "2016-04-29T23:07:44Z")

</div>

if you are using templates and UDT then there is a tag folder on the UDT called META, that contains the Tag Name and Tag Path.

[attachment=0]UDTMeta.PNG[/attachment]

---

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [May 2, 2016, 12:02pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/5 "2016-05-02T12:02:08Z")

</div>

That’s the data I’m after but it wouldn’t just be in templates. I would be using these tags in other places like transaction groups.

It’s not the end of the world if it can’t be done. I have the opportunity to start with a clean slate on a new project and thought this would be better than what I’m currently doing which is overwriting a memory tag for each instance of a UDT.

---

<div class="post-metadata">

**Author:** ![Chris\_Taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_taylor/32/3315_2.png) [@Chris\_Taylor](https://forum.inductiveautomation.com/u/Chris_Taylor)\
**Post date:** [May 2, 2016, 3:58pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/6 "2016-05-02T15:58:31Z")

</div>

I just had a play with this to see if I could so it, it should be easy to get the tagpath of a tag, but its not. Its not a tag attribute and there is no expression to retrieve it. Interesting, perhaps its a good candidate for a suggestion, it could be very useful.

---

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [May 2, 2016, 5:37pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/7 "2016-05-02T17:37:10Z")

</div>

Thanks for the sanity check. I too thought it would be easy and I was just missing something obvious ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [May 31, 2023, 4:27pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/8 "2023-05-31T16:27:58Z")

</div>

This post is LONG overdue, but a forum search led me here, so posting my results for future inquiries.

Regarding (non-UDT) relative tag referencing, you should be able to get the name of a tag (folder) by adding a suffix of ".Name" to your tag path.  
For example, if you wanted to grab the value of tag within a specific tag provider (of which happens to have the same name as the parent folder this new expression tag resides in), the following expression should work:

`tag("[" + {[.].Name} + "]" + "Path/To/Tag")`

If utilizing UDTs, a better option might be to utilize built-in parameters of UDTs: {InstanceName}, {PathToParentFolder}, etc.

Edit: Updated case (.Name vs .name)

---

<div class="post-metadata">

**Author:** ![stefanoranghetto](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@stefanoranghetto](https://forum.inductiveautomation.com/u/stefanoranghetto)\
**Post date:** [November 4, 2023, 12:34pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/9 "2023-11-04T12:34:44Z")

</div>

I ran into this problem... any ideas on how to find the name of the parent parent folder?

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [November 6, 2023, 7:21pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/10 "2023-11-06T19:21:20Z")

</div>

If you mean, you want a tag to contain the value matching the name of the grandparent folder.... I admit, I thought that task would have been easier...

Some helpful docs on relative referencing within expressions:  
[https://docs.inductiveautomation.com/display/DOC81/Tag+Paths](https://docs.inductiveautomation.com/display/DOC81/Tag+Paths)

From within an expression tag:  
`{[.].Path}` = Returns [provider]path/to/parent folder

And, while: `{[.]..}` = Grandparent folder (obtained by 'insert tag' then clicking on parent parent folder)...  
I was unable to figure out a way to get the name of said-folder without string manipulation on the `{[.].Path}` string.  
For example, path of grandparent folder might resemble:

```auto
left({[.].Path},lastIndexOf(toString({[.].Path}),"/"))

```

Or, you can access the name of any of the parent folders from a dataset tag containing the following expression:

```auto
split({[.].Path},'/')

```

Or, extracting the grandparent folder name only (from above dataset) in a string expression tag:

```auto
split({[.].Path},'/')[(len(split({[.].Path},'/'))-2),0]

```

Where len(x)-1 = parent, len(x)-2 = grandparent, etc.  
Unfortunately, nothing I found was terribly elegant... perhaps others can chime-in.

Edit: Updated case (.Path vs .path)

---

<div class="post-metadata">

**Author:** ![stefanoranghetto](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@stefanoranghetto](https://forum.inductiveautomation.com/u/stefanoranghetto)\
**Post date:** [November 6, 2023, 9:13pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/11 "2023-11-06T21:13:56Z")

</div>

first, thank you a lot.

but this becomes very hard to maintain!!!!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 6, 2023, 9:19pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/12 "2023-11-06T21:19:07Z")

</div>

> [@stefanoranghetto](#):
>
> very hard to maintain!

The fundamental problem is a tag hierarchy and/or UI structure that requires you to know the parent path. Instead:

- Pass folder names (including UDT instances) as "tagPath' parameters wherever you will do indirect binding.

- Concatenate `/someInnerName` and/or `.somePropName` in indirect bindings and when supplying tag paths to nested UI elements.

- Use `../` relative names only within a single UDT where an element in the UDT is referencing something else in the same UDT. If you need relative paths anywhere else, you've screwed up. (Or **somebody** has.)

---

<div class="post-metadata">

**Author:** ![stefanoranghetto](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@stefanoranghetto](https://forum.inductiveautomation.com/u/stefanoranghetto)\
**Post date:** [November 6, 2023, 9:30pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/13 "2023-11-06T21:30:38Z")

</div>

Hi Phil,  
thanks ... at the origin, my idea was about an alarm ... for example in the "Label" put a parent parent folder name just because my tag hierarchy is almost like:  
ZZZZ/ALM/alm00  
where  
ZZZZ: is my Zone name  
ALM: a folder with zone alarms...  
alm00: a tag with the alarms  
so it would be great if I could link the parent-parent folder name.  
Just looking for an elegant way or a way that I do not need to write too much code 🙂 because i normally lazy.

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [November 6, 2023, 11:05pm UTC](https://forum.inductiveautomation.com/t/get-name-from-folder-in-tag-browser/11601/14 "2023-11-06T23:05:36Z")

</div>

It would be handy to utilize a UDT for this...if possible.  
Would you be able to share a screenshot of your current tag structure, and perhaps some details of sample alarm descriptions, etc?
