iTunes standard file naming



Format value "FILENAME": $if($eql(%discnumber%,1/1),$num(%track%,2) $replace(%title%,?,,/,,",,:,,*,),$num(%discnumber%,1)-$num(%track%,2) $replace(%title%,?,,/,,",,:,,*,_))

Format value "_FILENAME": $left(%_filename%,36)

Format value "_FILENAME": $trim(%_filename%)

I'm constantly changing my mp3's with better rips/encodes. Since I already have all my mp3s in my iTunes library, I need to have the exact filenames when exchanging the mp3's so I don't have to tell iTunes to search for the correct ones. I'm letting iTunes rename and sort all my mp3's itself.

First off, I just want to inform that all the mp3's that will be replacing the old ones, have the exact same tags as the older ones. No differences there.

So, what I'm looking for is to do an action in Mp3tag, that will rename the new mp3's with the same routine iTunes does. Then I'll just delete the old ones, and move the new ones to the same folder, un-check the songs in iTunes and recheck them to update the info in iTunes.

Alright, this is the action I have at the moment:

Format value "_FILENAME": %track% %title%
Format value "_FILENAME": $left(%_filename%,36)

[kinda solved]*Standard albums with discnumber 1/1 should be renamed without discnumber in front of the tracknumber in the filename.

[solved]*All the filenames cannot contain more than 36 characters (32+4).

[solved]*What I'm looking for now is how to replace certain characters from the %title% tag, such as / ? and ", instead they should be replaced in the filename by an underline (_).

[solved]*I'll need a somewhat different action for albums with multiple discs, they need the discnumber in front of the tracknumber. Example:
1-01 Take On Me.mp3
1-02 Train Of Thought.mp3

2-01 Take On Me [Demo Version].mp3
2-02 Train Of Thought [Demo Version].mp3


[solved]*Another thing I need to do as well is the results of certain title schemes, how the end of the filename is renamed. In example if a song is above 32 characters, and the 32nd character is a space ( ), this will be discarded in the filename by iTunes.
Example for discnumber 1 track 14 and title:
Hunting High And Low [Extended Mix]
will be renamed to:
1-14 Hunting High And Low [Extended.mp3
instead of
1-14 Hunting High And Low [Extended .mp3

Hope y'all understand, and maybe we can have some sort of summary in the end of how to rename files just as iTunes does.

If it's impossible to achieve all this with mp3tag, I guess I'll just keep with my regular routing, which is with renaming with Tag&Rename and then use A.F.5 rename your files to shorten the characters. But it would be really sweet to do everything with Mp3tag in one action.

Action for adding album art automatically

If you have all the data there in tags you could easily rename

Format value "_FILENAME": %discnumber%-$num(%track%,2) %track% %title%
then cut the filename as you did
Format value "_FILENAME": $left(%_filename%,36)
and then trim the filename to cut off the blanks
Format value "_FILENAME": $trim(%_filename%)


Thank you ohrenkino!

However the format you used did not work as I need it to, but I learned a little from it, and also think I've learned how to replace certain characters and this is what I ended up with:

Format value "FILENAME": $num(%discnumber%,1)-$num(%track%,2) $replace(%title%,?,,/,,",,:,,*,)
Format value "_FILENAME": $left(%_filename%,36)
Format value "_FILENAME": $trim(%_filename%)

I don't know if the first action can be simplified, please correct me. It seems to work anyways.
I set it to replace ? / " : and * so far, I'll add more when I'll see it's needed.

The last thing I need to do now is to have ONE action that will cover both single disc albums and multiple discs albums. You see iTunes names files according to how many discs the album has. Single disc filenames does NOT include the disc number before the tracknumber on the files, but multiple disc albums DOES include the discnumber.

A single disc album's first track filename would look like this:
01 Take On Me.mp3
while a multiple disc album's first track filename would look like this:
1-01 Take On Me.mp3

I'm guessing I could use the $if(x,y,z) for this, but I don't know much about scripting. I'm guessing it would look something like this in the end though:

$if(%discnumber% is 1/1,
$num(%track%,2) $replace(%title%,?,,/,,",,:,,,),
$num(%discnumber%,1)-$num(%track%,2) $replace(%title%,?,


Am I on the right track?


Have you tried it on a single track to see the result?
I think you are by now deep enough into the intricacies that you can optimize your actions yourself.


Not quite there, I don't understand the '$if(x,y,z)' and if that is the one I could use.

If I could find some examples maybe I could figure it out, can't find any though.


In general, yey, you could use it.
But one gets tangled up easily in the number of brackets.

Coming to your example:
$if(%discnumber% is 1/1,
has to be modified to
$if($eql(%discnumber% ,'1/1'),.....

as the filter syntax does not apply.


Thank you so much for getting me on the right track. Some things I can figure out, just need a little helping hand :wink:

This is what I've ended up with, and it seems to be working, Standard iTunes naming:

Format value "FILENAME": $if($eql(%discnumber%,1/1),$num(%track%,2) $replace(%title%,?,,/,,",,:,,*,),$num(%discnumber%,1)-$num(%track%,2) $replace(%title%,?,,/,,",,:,,*,_))

Format value "_FILENAME": $left(%_filename%,36)

Format value "_FILENAME": $trim(%_filename%)

If anyone has any other suggestions, please add a comment!