# Create tag from filename: problems with spaces

**URL:** https://community.mp3tag.de/t/create-tag-from-filename-problems-with-spaces/9859
**Category:** Support
**Created:** [February 9, 2010, 4:04pm UTC](https://community.mp3tag.de/t/create-tag-from-filename-problems-with-spaces/9859 "2010-02-09T16:04:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Spessartine](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Spessartine](https://community.mp3tag.de/u/Spessartine)
#### Post date: [February 9, 2010, 4:04pm UTC](https://community.mp3tag.de/t/create-tag-from-filename-problems-with-spaces/9859/1 "2010-02-09T16:04:37Z")

</div>

I have a large number of mp3's (with no tags) with the following filename structure:

**Artist - Album Track# - Title** ; notice there are no hyphens between album and track#;

which I would like to create tags for. However some of the album names have multiple words:

**Artist - Al Bum Track# - Title** ;

so when I attempt to use the simple "Filenames to Tag" option:

_%artist% - %album% %track% - %title%_

I end up getting part of the album name in the number field (i.e., using the above example, the album tag is only " **Al**" and the track number comes out as " **Bum Track#**"). I've only just started using Mp3Tag, and can't seem to figure it out on my own.

Ideally, is there a way to get Mp3Tag to recognize that the track#'s are the two-digit numbers separated by a space from the last hyphen ONLY? And that everything before that space-two-digits-space string is the album name?

I'm computer savvy enough to use code, but not to come up with my own without some intense study, if that helps. Any assistance would be greatly appreciated.

---

<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: [February 9, 2010, 5:51pm UTC](https://community.mp3tag.de/t/create-tag-from-filename-problems-with-spaces/9859/2 "2010-02-09T17:51:11Z")

</div>

> [@Spessartine](#):
>
> ... **Artist - Album Track# - Title** ; notice there are no hyphens between album and track#; ...

You can try following ...  
... first change the structure of the filename using converter "filename to filename":

 

**Convert** | **Filename - Filename** | **ALT+3**

 

_Select format string_

 

Old filename pattern:  
**%1 - %2 %3 - %4**

 

New filename pattern:  
**%1 - %2 - %3 - %4**

 

Preview  
**Artist - Album - Track# - Title.mp3**

 

... then use converter "filename to tag":

 

**Convert** | **Filename - Tag** | **ALT+2**

 

_Select format string_

 

Formatstring: Artist - Album - Track# - Title.mp3  
**%artist% - %album% -%track% -%title%**

 

Preview  
**artist** | Artist  
**album** | Album  
**track** | Track#  
**title** | Title

 

DD.20100209.1952.CET

The other case can be handled this way ...

 

**Convert** | **Filename - Filename** | **ALT+3**

 

_Select format string_

 

Old filename pattern:  
**%1 - %2 %3 %4 - %5**

 

New filename pattern:  
**%1 - %2 %3 - %4 - %5**

 

Preview  
**Artist - Al bum - Track# - Title.mp3**

 

DD.20100209.1957.CET

Another way might be ...  
... first filtering the view [F3] with  
**%\_FILENAME% MATCHES "(.+?) - (.+?) (\d+) - (.+?)"**

.. then execute an action "Format value" using this regular expression function statement:  
**$regexp(%\_FILENAME%,'^(.+?) - (.+?) (\d+) - (.+?)$','$1 - $2 - $3 - $4')**

Afterwards you can de-struct the filename into tag field parts as usual.

DD.20100209.2008.CET

---

<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:22pm UTC](https://community.mp3tag.de/t/create-tag-from-filename-problems-with-spaces/9859/3 "2026-02-09T12:22:09Z")

</div>


