# Easy way to get directory names above Parent?

**URL:** https://community.mp3tag.de/t/easy-way-to-get-directory-names-above-parent/9324
**Category:** General Discussion
**Created:** [November 12, 2009, 7:20pm UTC](https://community.mp3tag.de/t/easy-way-to-get-directory-names-above-parent/9324 "2009-11-12T19:20:01Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [November 17, 2009, 10:41am UTC](https://community.mp3tag.de/t/easy-way-to-get-directory-names-above-parent/9324/6 "2009-11-17T10:41:41Z")

</div>

Following example of an Action Group "SplitFolderpath" demonstrates how to split the content of the Mp3tag system variable \_FOLDERPATH into it's folder components and make the folder names available for scripting by owner defined tag fields.

MY\_FOLDER\_0 is the parent folder of the related file.  
MY\_FOLDER\_1 is the next folder up.  
MY\_FOLDER\_2 is the folder two steps up.  
... and so on.

Begin Action Group **SplitFolderpath**

Action #1  
_Actiontype 5:_ **Format tag field**  
_Field:_ **MY\_FOLDERPATH**  
_Formatstring:_ **%\_FOLDERPATH%**

Action #2  
_Actiontype 16:_ **Split fields by separator**  
_Field:_ **MY\_FOLDERPATH**  
_Separator:_ **\</b\>**

Action #3  
_Actiontype 5:_ **Format tag field**  
_Field:_ **MY\_FOLDER\_0**  
_Formatstring:_ **$meta(MY\_FOLDERPATH,$sub($folderdepth(%\_FOLDERPATH%),0))**

Action #4  
_Actiontype 5:_ **Format tag field**  
_Field:_ **MY\_FOLDER\_1**  
_Formatstring:_ **$meta(MY\_FOLDERPATH,$sub($folderdepth(%\_FOLDERPATH%),1))**

Action #5  
_Actiontype 5:_ **Format tag field**  
_Field:_ **MY\_FOLDER\_2**  
_Formatstring:_ **$meta(MY\_FOLDERPATH,$sub($folderdepth(%\_FOLDERPATH%),2))**

Action #6  
_Actiontype 5:_ **Format tag field**  
_Field:_ **MY\_FOLDER\_3**  
_Formatstring:_ **$meta(MY\_FOLDERPATH,$sub($folderdepth(%\_FOLDERPATH%),3))**

Action #7  
_Actiontype 9:_ **Remove fields**  
_Fields to remove (semicolon separated):_ **MY\_FOLDERPATH**

End Action Group **SplitFolderpath** (7 Actions)

DD.20091117.1241.CET

---

_[View the full topic](https://community.mp3tag.de/t/easy-way-to-get-directory-names-above-parent/9324)._
