# Export m3u, sorted by Album

**URL:** https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169
**Category:** Support
**Created:** [March 22, 2018, 7:43am UTC](https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169 "2018-03-22T07:43:16Z")
**Posts on this page:** 6
**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: [March 22, 2018, 7:43am UTC](https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169/1 "2018-03-22T07:43:16Z")

</div>

Hi guys, currently generating m3u playlists via:

> $filename(%albumartist% - %album%.m3u,utf-8)#EXTM3U  
> $loop(%\_filename\_ext%)#EXTINF:%\_length\_seconds%,%discnumber%$num(%track%,2) - %artist% - %title% - %year%  
> %\_filename\_rel%  
> $loopend()

Only trouble with this is that they are sorted by filename, how to modify it that it would be sorted by directory?  
Sorting inside mp3tag column view does not to seem any effect on this.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [March 22, 2018, 8:19am UTC](https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169/2 "2018-03-22T08:19:55Z")

</div>

Hi Etz,

you'd use another `$loop` around the one that sorts by `%_filename_ext%` to sort by, e.g., `%_directory%`

```nohighlight
$filename(%albumartist% - %album%.m3u,utf-8)#EXTM3U
$loop(%_directory%)$loop(%_filename_ext%)#EXTINF:%_length_seconds%,%discnumber%$num(%track%,2) - %artist% - %title% - %year%
%_filename_rel%
$loopend()$loopend()

```

---

<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: [March 27, 2018, 8:39am UTC](https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169/3 "2018-03-27T08:39:10Z")

</div>

I actually came to another question now.

Any way to assign $filename dynamically?

Basically what I would like to achieve is have playlist name always as parent folder name.  
Catch is that if I export only from single folder it would be the %\_directory%, but if there are multiple files selected from multiple subfolders mp3tag defaults to first file directory.  
How to achieve, that in this case, it would use %\_parent\_directory%?

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [March 28, 2018, 7:22pm UTC](https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169/4 "2018-03-28T19:22:31Z")

</div>

Can you use `%_workingdir%` there?

---

<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: [March 28, 2018, 7:30pm UTC](https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169/5 "2018-03-28T19:30:07Z")

</div>

> [@Florian](#):
>
> %\_workingdir%

Neat idea, yes I can... ☀

---

<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:27pm UTC](https://community.mp3tag.de/t/export-m3u-sorted-by-album/41169/6 "2026-02-09T12:27:19Z")

</div>


