How to import txt tracklist to file name?


I always download some music which without track number in the tag, and the files have no track number before the file name. it's just like "AAAAA", not "01 AAAAA".

So, I want to import the tracklist to file name,

I have files:

and i get the track list with track number:

How can I import the track list to file name with MP3tag?
And make sure the tracks will match with the name and number.

I don't want to add track number one by one, coz some of the albums have a lot of tracks.

Thanks in advance!

At first your question looks as if it is easy to solve with the converter "Textfile - Tag".

But because the list file of "Track Filename" entries probably does not contain the filename as an absolute path name, then the converter "Textfile - Tag" can not afford the appropriate allocation between the current file and its related track number.

With the following action group, the problem is quickly finished.
In Action #1 adapt the filepath location of the input text file to your needs.

Begin Action Group Test_2013#MatchFilenameInListfile.GiveTrack

Action #1
Actiontype 14: Import text file
Field __: TMP_LIST
Filename: 'T:\TEST\Tracklist.txt'

Action #2
Actiontype 5: Format value
Field ______: TMP_LIST
Formatstring: $regexp($char(13)$char(10)%TMP_LIST%$char(13)$char(10),'\s*[\r\n]+\s*','\r\n')

Action #3
Actiontype 5: Format value
Field ______: TMP_FN
Formatstring: $regexp(%_filename%,'[\*+?|{}[]()^$.#\ ]','\\$0')

Action #4
Actiontype 5: Format value
Field ______: TRACK
Formatstring: $regexp(%TMP_LIST%,'^.\n(\d+)\s+('%TMP_FN%')\r.$','$1')

Action #5
Actiontype 5: Format value
Field ______: TRACK
Formatstring: $if($eql(%TRACK%,%TMP_LIST%),'0',%TRACK%)

Action #6
Actiontype 9: Remove fields
Fields to remove (semicolon separated): TMP_LIST;TMP_FN

End Action Group Test_2013#MatchFilenameInListfile.GiveTrack (6 Actions)

There is an archive file containing the test case.
20131117.pique.rar (2.5 KB)

20131117.pique.rar (2.5 KB)

Thank you very much!!! You helped me out!
Have a nice day :slight_smile:


I found a problem about the action 3:

If there're some special letters in the tracklist, such as "(", ")" etc...
There will be a problem of this action.
The track number will show all the track list.

Thank you.

Thank you for pointing this out.
See changes above in post #2 ...
How to import txt tracklist to file name?


Thank you.

But I think there's still a problem. And I don't know what is the problem.
Just some of the files are not ok.

Please check the file. :slight_smile: (2.76 KB)

Hello again,

Check this one, I think it's more clear. (2.76 KB)

The spelling is different:
Selling Rope (Swan Dive to Estuary)
Selling Rope (Swan Dive To Estuary)

Here is a case insensitive version ...
MatchFilenameInListfileCaseInsensitive.rar (999 Bytes)

MatchFilenameInListfileCaseInsensitive.rar (999 Bytes)

OMG... Thanks... I didn't see that.

I'll be more careful.

Thanks again! :slight_smile:

Hello, first of all, thanks for the help.

But it seems still have problem. When the file names don't match, the track numbers will be wrong. It just show "0".

Or maybe we can do it in this way:

Just replace the filename and the title IF the words matches, no matter it's uppercase or lowercase. Then add the track number in the track tag. Since the names have all matched, it will be easy to get the track numbers.

Just a suggestion, hope it will help.

Thanks anyway. :slight_smile:

Hm, I do not understand ... does it mean, that "MatchFilenameInListfileCaseInsensitive" does not work?
If the number '0' is irritating, you may replace the number '0' with the space character or leave the TRACK field just empty.



I think it doesnt work. If the file name in the tracklist doesn't match with the file name I have in my computer, when I do the action group, the track number will be written an "0".
The others which names matched will be OK.

Thank you.

Hm, yes, you have described exactly the principle of matching.
Therefore the TRACK '0' can be a mark for you to check the spelling of the related filename.


OK, Thank you.

That will be an idea to check if the names are right. :slight_smile:

Hello, sorry to bother again.

I found it's just like earlier, when there're some special letters like: (, ), $, @ and letters from some other languages (French, germany and etc), the track numbers will show empty. Even the names match.

I mentioned the "0", because I added "tag - filename" to the end of this action, that's why it shows "0", the real reason is the track number tag is empty.

Thank you very much for all the help.

Please give some more examples of your mystery names.
The already escaped characters "$()" should work in the given regular expression.
The symbol @ should also make no harm.
The comma might hurt, so put it in the list of escaped characters too:

$regexp(%TMP_FN%,'[\\\*\+\?\|\{\}\[\]\(\)\^\$\.\,\#\ ]','\\\\$0')

Alternatively you may try this expression, which escapes each character.



Thank you, I will take a note next time when I get the problem and give you an example.

Have a nice day! :slight_smile: