# Replace characters in filename playlist creation

**URL:** https://community.mp3tag.de/t/replace-characters-in-filename-playlist-creation/15715
**Category:** Support
**Created:** [May 5, 2014, 11:58am UTC](https://community.mp3tag.de/t/replace-characters-in-filename-playlist-creation/15715 "2014-05-05T11:58:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gsa999](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/c6cbf5/32.png) [@gsa999](https://community.mp3tag.de/u/gsa999)
#### Post date: [May 5, 2014, 11:58am UTC](https://community.mp3tag.de/t/replace-characters-in-filename-playlist-creation/15715/1 "2014-05-05T11:58:12Z")

</div>

Hi  
I'm trying to write an action that trawls through all my mp3s in all folders and creates a playlist in each folder

The code below works fine:

```
$filename(%_folderpath%\$if($eql(%albumartist%,Various Artists),$cutleft(%album%,6),%artist% - $cutleft(%album%,6)).m3u8,utf-8)#EXTM3U
#EXTART:$if($eql(%albumartist%,Various Artists),%albumartist%,%artist%)
#EXTALB:%album%
$loop(%track%)$loop(%_filename_ext%)#EXTINF:%_length_seconds%,%artist% - %title%
%_filename_ext%
$loopend()$loopend()

```

However - if I have artists or albums with with / or : in them I want to replace them with -  
The code below does not work and does not even create a playlist. I have tried wrapping the $replace function around $filename function and within it - neither works

```
$filename($replace(%_folderpath%\$if($eql(%albumartist%,Various Artists),$cutleft(%album%,6),%artist% - $cutleft(%album%,6)),/,-,:, - ).m3u8,utf-8)#EXTM3U
#EXTART:$if($eql(%albumartist%,Various Artists),%albumartist%,%artist%)
#EXTALB:%album%
$loop(%track%)$loop(%_filename_ext%)#EXTINF:%_length_seconds%,%artist% - %title%
%_filename_ext%
$loopend()$loopend()

```

Any ideas  
Thanks  
G

---

<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: [May 5, 2014, 12:50pm UTC](https://community.mp3tag.de/t/replace-characters-in-filename-playlist-creation/15715/2 "2014-05-05T12:50:40Z")

</div>

> [@gsa999](#):
>
> ... if I have artists or albums with with / or : in them I want to replace them with - ...

For example ... here is the underline character used instead of the hyphen minus character ...

**$filename(%\_folderpath%$replace($if($eql(%ALBUMARTIST%,'Various Artists'),$cutLeft(%ALBUM%,6),%ARTIST%'/:\* - '$cutLeft(%ALBUM%,6))'.m3u8','/','\_',':','\_','\*','\_'),utf-8)**

... or ...

**$filename(%\_folderpath%$replace($if($eql(%ALBUMARTIST%,'Various Artists'),$cutLeft(%ALBUM%,6),%ARTIST%'/:\* - '$cutLeft(%ALBUM%,6)),'/','\_',':','\_','\*','\_')'.m3u8',utf-8)**

... or ...

**$filename(%\_folderpath%$regexp($if($eql(%ALBUMARTIST%,'Various Artists'),$cutLeft(%ALBUM%,6),%ARTIST%'/:\* - '$cutLeft(%ALBUM%,6)),'[/:\*]','\_')'.m3u8',utf-8)**

Example for a MTE script ...

**01: $filename(%\_folderpath%$regexp($if($eql(%ALBUMARTIST%,'Various Artists'),$cutLeft(%ALBUM%,6),%ARTIST%' - '$cutLeft(%ALBUM%,6)),'[/:\*]','\_')'.m3u8',utf-8)$puts(** 

**02: )'#EXTM3U'  
03: '#EXTDATE - original creation date of the playlist'  
04: '#EXTAUTHOR - playlist author'  
05: '#EXTCOVER - name and location of an image file with the CD cover art'  
06: '#EXTBACK - same as #EXTCOVER, but backside'  
07: '#EXTINLET - same as #EXTCOVER, but inlet, maybe multiple'  
08: '#EXTIMAGE - generic associated image, maybe multiple'  
09: $loop(%TRACK%)$loop(%\_filename\_ext%)  
10: '#EXTARTIST '%ARTIST%  
11: '#EXTALBUM'%ALBUM%  
12: '#EXTTITLE'%TITLE%  
13: '#EXTNUMBER '%TRACK%  
14: '#EXTINF'%\_length\_seconds%','%ARTIST%' - '%TITLE%  
15: %\_filename\_ext%  
16: $loopend()$loopend()**

 

DD.20140505.1835.CEST

---

<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/replace-characters-in-filename-playlist-creation/15715/3 "2026-02-09T12:25:02Z")

</div>


