# Filename function in export configurations

**URL:** https://community.mp3tag.de/t/filename-function-in-export-configurations/15820
**Category:** Support
**Created:** [June 18, 2014, 5:18pm UTC](https://community.mp3tag.de/t/filename-function-in-export-configurations/15820 "2014-06-18T17:18:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [June 18, 2014, 5:18pm UTC](https://community.mp3tag.de/t/filename-function-in-export-configurations/15820/1 "2014-06-18T17:18:53Z")

</div>

I can't figure out how to use it.  
The help says:

> [@](#):
>
> You can set the filename of the exported file with the function $filename(name[,enc]). The optional second parameter sets the encoding of the export file. Possible values are ansi, utf-8 and utf-16.  
> $filename(test.txt)  
> $filename(test.txt,ansi)  
> $filename(test.txt,utf-8)  
> $filename(test.txt,utf-16)

but my file always ends up with the "Export file name" from the "Export" window (Mp3tag won't let me leave that field blank).

---

<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: [June 19, 2014, 3:53am UTC](https://community.mp3tag.de/t/filename-function-in-export-configurations/15820/2 "2014-06-19T03:53:11Z")

</div>

> [@aax](#):
>
> I can't figure out how to use it. ...

Here is an example export script, have a closer look at the $filename directive ...

**1: $filename($getEnv('USERPROFILE')'\Desktop\Mp3tag.Report.tagdump.'$replace(%\_datetime%,' ','.','-',)'.txt',UTF-8)** 

**2: $loop(%_path%__)'^'  
3: $regexp($regexp($list(,': ''',''$char(13)'_'$char(10)),'\r\n','U+000DU+000A'),'\r\_\n','\r\n')'\*'  
4: $regexp($regexp($listtec(,': ''',''$char(13)'_'$char(10)),'\r\n','U+000DU+000A'),'\r_\n','\r\n')'$'  
5: $loopend()  
6: 'MP3TAGAPP: '''$getEnv('MP3TAGAPP')''  
7: 'MP3TAGAPPDATA: '''$getEnv('MP3TAGAPPDATA')''**

 

DD.20140619.0753.CEST

---

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [June 19, 2014, 12:10pm UTC](https://community.mp3tag.de/t/filename-function-in-export-configurations/15820/3 "2014-06-19T12:10:35Z")

</div>

Hmm, do I **need** some kind of path placeholder (e.g %\_directory%) for it to work?

Does it matter what I put in "Export file name" box of "Export" window, or will the filename function from the export configuration .mte override it?

---

<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: [June 19, 2014, 3:28pm UTC](https://community.mp3tag.de/t/filename-function-in-export-configurations/15820/4 "2014-06-19T15:28:16Z")

</div>

> [@aax](#):
>
> Hmm, do I **need** some kind of path placeholder (e.g %\_directory%) for it to work? Does it matter what I put in "Export file name" box of "Export" window, or will the filename function from the export configuration .mte override it?

Indeed, there is no need to code a $filename function into a Mp3tag export script.  
Using this export script ...

**1: 'Test - export script without $filename directive.'** 

**2: $loop(%\_path%)  
3: %\_counter%' - '%\_path%  
4: $loopend()**

 

... and filling in a properly named file path into the edit field for the filename within the "Export" dialog, ... let Mp3tag create the named output text file, e. g. 'T:\TEMP\TEST.TXT'.  
In this way, the output text will be always encoded as ANSI.

 

I prefer the way to code the file path to the export's output file directly into the MTE export script, using the $filename function.  
In this way, the user can control the output text encoding to be ANSI, UTF-16 or UTF-8, by setting the second parameter of the $filename function to the wanted value.

 

The file path to the export's output file is scriptable.  
The file path can be written as one literal string, ...  
or can be assembled from several parts of 'literal string' or %tagfield% value or %\_system% value or $function() output.

 

Once the export's output file path has been defined or changed within the export script, it is recommended to update the memory of the "Export" dialog edit field, by moving the pick list selection bar over the name of the related export script, ...  
... well ... this is rather quirky, but it seems to work.

 

DD.20140619.1928.CEST

---

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [June 19, 2014, 3:51pm UTC](https://community.mp3tag.de/t/filename-function-in-export-configurations/15820/5 "2014-06-19T15:51:30Z")

</div>

> [@DetlevD](#):
>
> Once the export's output file path has been defined or changed within the export script, it is recommended to update the memory of the "Export" dialog edit field, by moving the pick list selection bar over the name of the related export script, ...  
> ... well ... this is rather quirky, but it seems to work.

Ah! Got it now. Very quirky, indeed. 😳  
So, the file will always be named after "Export file name" box ("Dateiname der Exportdatei") of "Export" window regardless of $filename function in .mte, so I have to make sure to update that box with $filename function by clicking the desired export script in "Export" window.

---

<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/filename-function-in-export-configurations/15820/6 "2026-02-09T12:25:06Z")

</div>


