# Extracting AlbumArtist and Album from Directroy structure

**URL:** https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546
**Category:** Support
**Created:** [January 29, 2015, 10:45am UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546 "2015-01-29T10:45:47Z")
**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: [January 29, 2015, 1:05pm UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/6 "2015-01-29T13:05:41Z")

</div>

> [@Etz](#):
>
> ... And that is the tricky part actually, not all Albums have multiple volumes...

You can handle such problems by using the method "divide and conquer" ...  
at first treat the first case, then treat the second case ...  
so ... set the Mp3tag Filter ... for example to count the backslashes ...  
and apply the dedicated action group.

**"$sub($len(%\_path%),$len($replace(%\_path%,'\',)))" IS 4**

resp.

**"$sub($len(%\_path%),$len($replace(%\_path%,'\',)))" IS 5**

... or ...

**"$regexp(%\_path%,'[^\\\\]',)" IS "\\\\"**

resp.

**"$regexp(%\_path%,'[^\\\\]',)" IS "\\\\\"**

... or...

**"$folderdepth(%\_folderpath%)" IS 3**

resp.

**"$folderdepth(%\_folderpath%)" IS 4**

... or ... use ... action "Format value" with ...

**Formatstrings to fetch folder item from folderpath Example: %\_folderpath% = "Z:\A4\B3\C2\D1\" Up 1 level : $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\$','$1') ==\> "D1" Up 2 levels: $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\.+?\\\\$','$1') ==\> "C2" Up 3 levels: $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\.+?\\\\.+?\\\\$','$1') ==\> "B3" Up 4 levels: $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\.+?\\\\.+?\\\\.+?\\\\$','$1') ==\> "A4" Up 1 level : $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\(?:(.+?)\\\\){0}$','$1') ==\> "D1" Up 2 levels: $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\(?:(.+?)\\\\){1}$','$1') ==\> "C2" Up 3 levels: $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\(?:(.+?)\\\\){2}$','$1') ==\> "B3" Up 4 levels: $regexp(%\_folderpath%,'^(?:.+?\\\\)\*(.+?)\\\\(?:(.+?)\\\\){3}$','$1') ==\> "A4" Level 0: $regexp(%\_folderpath%,'^(?:.+?\\\\){0}(.+?)\\\\.\*$','$1') ==\> "Z:" Level 1: $regexp(%\_folderpath%,'^(?:.+?\\\\){1}(.+?)\\\\.\*$','$1') ==\> "A4" Level 2: $regexp(%\_folderpath%,'^(?:.+?\\\\){2}(.+?)\\\\.\*$','$1') ==\> "B3" Level 3: $regexp(%\_folderpath%,'^(?:.+?\\\\){3}(.+?)\\\\.\*$','$1') ==\> "C2" Level 4: $regexp(%\_folderpath%,'^(?:.+?\\\\){4}(.+?)\\\\.\*$','$1') ==\> "D1"**

... or ...  
... using function $meta() ...  
[unterschiedlicher Aufbau von Dateinamen](https://community.mp3tag.de/t/12021/4)

... or ...  
... use the action "Guess values" ...  
Source format: %\_folderpath%  
Formatstring: %dummy%\<!--coloro:#808080--\>%dummy%\%ALBUMARTIST%\%ALBUM%\<!--coloro:#808080--\>%dummy%

X:\Music\Albumartist\Album\Files.extX:\Music\Albumartist\Album\Volume\Files.ext

DD.20150129.1620.CET, DD.20150129.1946.CET

---

_[View the full topic](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546)._
