# 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:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)
#### Post date: [January 29, 2015, 10:45am UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/1 "2015-01-29T10:45:47Z")

</div>

I currently have things organized in two ways:

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

and

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

Is there a easy way, to extract Albumartist and Album from both formats?

I currently have defined two separate actions for those, but this makes handling things complicated.  
Maybe someone can suggest more universal approach? ![:rolleyes:](https://community.mp3tag.de/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif ":rolleyes:")

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [January 29, 2015, 10:48am UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/2 "2015-01-29T10:48:33Z")

</div>

If the first part of the path stays the same, you may stand a chance. Try:  
X:\Music\%Albumartist%\%Album%\%dummy%

This is a mask for Convert\>Filename-Tag

---

<div class="post-metadata">

### Author: ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)
#### Post date: [January 29, 2015, 11:00am UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/3 "2015-01-29T11:00:03Z")

</div>

Does not work, have tried already...

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

%AlbumArtist% = Album  
%Album% = Volume

What I actually is trying to achieve is that in such occasions, when subfolder "Volume" exists (Vol. 1 for example), it would get merged to %Album% field.

So %Album% would look like "Album Volume"

And yes, path is exactly same for all files eq. "X:\Music"

---

<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, 11:23am UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/4 "2015-01-29T11:23:20Z")

</div>

> [@Etz](#):
>
> ... I currently have defined two separate actions for those, but this makes handling things complicated. ...

Please show us which actions you have created so far.

DD.20150129.1323.CET

---

<div class="post-metadata">

### Author: ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)
#### Post date: [January 29, 2015, 11:37am UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/5 "2015-01-29T11:37:29Z")

</div>

> [@DetlevD](#):
>
> Please show us which actions you have created so far.
> 
> DD.20150129.1323.CET

For X:\Music\Albumartist\Album\Files.ext

```
[#0]
T=7
F=%_parent_directory%
1=%albumartist%

[#1]
T=7
F=%_directory%
1=%album%

[#2]
T=7
F=%filename%
1=%discnumber%-%track% - %artist% - %title%

```

Now, that does not work for: X:\Music\Albumartist\Album\Volume\Files.ext

And that is the tricky part actually, not all Albums have multiple volumes...

---

<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

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [January 29, 2015, 5:12pm UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/7 "2015-01-29T17:12:46Z")

</div>

> [@Etz](#):
>
> Does not work, have tried already...
> 
> X:\Music\Albumartist\Album\Volume\Files.ext becomes:
> 
> %AlbumArtist% = Album  
> %Album% = Volume
> 
> What I actually is trying to achieve is that in such occasions, when subfolder "Volume" exists (Vol. 1 for example), it would get merged to %Album% field.
> 
> So %Album% would look like "Album Volume"
> 
> And yes, path is exactly same for all files eq. "X:\Music"

Then you have not entered the path including the drive letter.  
Please note that the mask looks like this:  
X:\Music\%Albumartist%\%Album%\%dummy%  
This includes the path starting at the drive.

---

<div class="post-metadata">

### Author: ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)
#### Post date: [January 29, 2015, 5:43pm UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/8 "2015-01-29T17:43:35Z")

</div>

> [@ohrenkino](#):
>
> Then you have not entered the path including the drive letter.  
> Please note that the mask looks like this:  
> X:\Music\%Albumartist%\%Album%\%dummy%  
> This includes the path starting at the drive.

Yep, you are right...my mistake... ![:rolleyes:](https://community.mp3tag.de/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif ":rolleyes:")

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:25pm UTC](https://community.mp3tag.de/t/extracting-albumartist-and-album-from-directroy-structure/16546/9 "2026-02-09T12:25:30Z")

</div>


