# Playlist creation using an Export script

**URL:** <https://community.mp3tag.de/t/playlist-creation-using-an-export-script/56474>\
**Category:** Support\
**Created:** [February 24, 2022, 6:23pm UTC](https://community.mp3tag.de/t/playlist-creation-using-an-export-script/56474 "2022-02-24T18:23:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Montemerano](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/b3f665/32.png) [@Montemerano](https://community.mp3tag.de/u/Montemerano)\
**Post date:** [February 24, 2022, 6:23pm UTC](https://community.mp3tag.de/t/playlist-creation-using-an-export-script/56474/1 "2022-02-24T18:23:17Z")

</div>

Hello community,

I have been using Mp3tag for a while to manage my music collection, but I have previously not used the more advanced features such as Actions and Scripting. I have to admit, I am really struggling in trying to understand their usage. If my questions seem a bit basic, then please forgive my ignorance...

My objective is to create various playlists based on criteria such as a specific artist (eg. Roxy Music), a genre (eg. Pop), or a time span (1990-1999).

Having read through the many community posts, my understanding is that the recommended approach would be to create an Export script.

I have started to create a simple playlist creation script as shown below to scan (loop) through my music collection. I am using the $if function to select entries matching a specific artist (in this case, Roxy Music).

#EXTM3U  
$loop(%\_path%)  
$if($eql(%artist%,'Roxy Music'),Match,NoMatch)  
.....  
$loopend()

I am struggling with the syntax of the $if function above. The "Match" and "NoMatch" shown above are simply placeholders to help you understand what I am trying to do.

When the $if function returns true (ie. Match, an entry is found that matches the desired artist), then the following lines should be written to the playlist file:

#EXTINF:%\_length\_seconds%,%artist% - %title%  
..\FLAC%artist%%album%%\_filename\_ext%

When the $if function returns false (ie. NoMatch) then nothing should be written to the playlist file.

I would really appreciate some guidance on how to correctly code the script.

Thanks very much for your efforts!

---

<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:** [February 24, 2022, 6:31pm UTC](https://community.mp3tag.de/t/playlist-creation-using-an-export-script/56474/2 "2022-02-24T18:31:08Z")

</div>

TBH: I find the idea to create an export script with a more or less complicated conditional query in it rather awkward.  
I would use a filter with  
%artist% HAS "Roxy Music"  
or even  
%artist% IS Roxy Music  
and then apply a generic export script for a playlist or use the already out-of-the box function  
File\>Playlist (all files)  
or  
File\>Playlist (selected files).  
If you use the filtern then you don't have to edit the export script for every new criterion.

If you insist on an export script, and you want to get the same order as the file list, then don't use  
$loop(\_path%) but $loop(1) - otherwise the files will be arranged by path which may not be what you like.

---

<div class="post-metadata">

**Author:** ![Montemerano](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/b3f665/32.png) [@Montemerano](https://community.mp3tag.de/u/Montemerano)\
**Post date:** [February 27, 2022, 5:19pm UTC](https://community.mp3tag.de/t/playlist-creation-using-an-export-script/56474/3 "2022-02-27T17:19:39Z")

</div>

Hi Ohrenkino...  
Thanks for the quick response and your recommendations.  
I have done some initial testing using filters and they appear to work just fine. It is definitely much easier to use filters than to create export scripts.  
I think the filters will be quite sufficient for my needs.  
Thanks again!

---

<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:** [March 29, 2022, 5:20pm UTC](https://community.mp3tag.de/t/playlist-creation-using-an-export-script/56474/4 "2022-03-29T17:20:24Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
