Regexp not working as expected in convert --> tag - filename ?

I am trying to relocate a bunch of mostly untagged/unmatched tracks in a given folder using convert --> tag - filename ..

My format string is:
e:\path$if2(%artist%,'unknown-artist')$if2(%album%,'unknown-album')$if2(%title%,$regexp(%_filename%,^\s*[0-9]\s-\s[0-9]\s) )

The logic being to remove leading spaces, digits and dashes in front of the filename, and use that as the track's filename ..

Generally, I have been reading the regexp topics .. eg: /t/521/1

But it seems that not all regexps acceptable in an action are available for use in the $regexp function in specifying format strings .. because most would give REGEXP error in the preview window ..

I have unsuccessfully tried quite a few different ways at specifying a valid regexp to do this .. and almost always running into regexp errors ..

I suspect I am missing something obvious, or working blindside of commonly known issues with using this section ..

Please, can anyone help point me in the right direction ..

Thanks in advance

Just wanted to point out that I do realize I have no replacement for the matched string in that format string ..

The reason for that is that it is not obvious to me how to specify NULL as replacement .. and I already tried using ( ) to select a sub-match, and then using $1 to apply the sub-match as replacement .. and I was getting regexp error ..

So, I would appreciate an example on how to specify NULL as a replacement value .. and or how to apply sub-matches as replacement

Try this:


The single quotes escape characters that have special meaning in Mp3tag eg. []
Specify NULL by not entering anything after the last comma.

Awesome .. thanks a million ..

I knew it had to be something 'obvious' like that .. more than incorrect regexp

That certainly works great .. with character sets or not .. I tried character sets first because they are so much more legible and short ..

Another question .. pertains to use of absolute paths ..

How do I specify a starting absolute path for the conversion?

I started my format string with e:\dir\dir .. but instead of actually using the absolute path, mp3tag created these path elements under the folder where the songs to be renamed where .. like:
!-- dir

!-- dir 

It would seem obvious that using placeholders like %_parent_directory%, %_directory%, etc is the way to go .. but my previous attempt at using those yielded incorrect results due to the different levels of nesting of the individual tracks ..

Any suggestions would be appreciated ..

Please be more closely, which action or converter is involved, show a practical example.


This is a continuation of my initial post in this topic .. I am doing Convert --> tag - filename

And in the format string, I have used:
e:\dir\dir$if2(%artist%,'unknown-artist')$if2(%album%,'unknown-album')$if2(%title%,$regexp(%_filename%,'^\s*[0-9]\s-\s[0-9]\s',) )

The preview seemed to suggest it would work and the files will be written at the correct absolute path .. but that did'nt happen. Instead the files were written with respect to the current top directory where the tracks being renamed reside.

Here's a format string template for Tag to Filename conversion.
It will move files to a folder below the directory in which they currently exist.

%_folderpath%Some Folder\Another Folder\\%_filename%

%_folderpath% includes a trailing backslash.
New folders are created as necessary.

Against a media file, having ARTIST, ALBUM, TITLE filled with correct values, this formatstring has been applied in converter "Tag-Filename" and Mp3tag has done it as expected.

'e:\dir\dir\'$if2(%ARTIST%,'unknown-artist')'\'$if2(%ALBUM%,'unknown-album')'\'$if2(%TITLE%,$regexp(%_filename%,'^[\d\s-]*',)' ')

The formatstring moved the selected media file into a subfolder tree on drive E, for example ...
"T:\TEST\Testalbum\123 - Testfile.mp3" ->

Against a media file, having set no tagfields ARTIST, ALBUM, TITLE, the formatstring has been applied in converter "Tag-Filename" and Mp3tag has done it as expected.

The formatstring moved the selected media file into a subfolder tree on drive E, for example ...
"T:\TEST\Testalbum\123 - Testfile.mp3" ->
"e:\dir\dir\unknown-artist\unknown-album\Testfile .mp3"

Even the filename with the trailing space has been created as designed in the formatstring.


Sorry, been late in getting back to this .. been travelling ..

Yes, I see the solution in your post, DetlevD .. thanks .. literal directory specification in the format string need to be quoted in single quotes .. just like the regexp ..

Thanks to all who responded for all the suggestions and responses .. I have improved my understanding of how mp3tag works ..