Strange Tag to Filename issue

I have the following script running on the Alt-1 process Tag>Filename:

%albumartist%\%album%$num(%discnumber%,1) $num(%track%,2) %albumartist%

Every time I run an action or a script I do a refresh of the screen (F5) beforehand, and most of the time when it's done the message is "(number) of (total) files renamed", and I always look for the 0 in (number) to confirm that everything's gone fine.

But sometimes a situation will come up, like an album has the exact same name as the album artist, and then no matter how many times I run the above script and refresh the screen, it will always say that some files have been renamed.

Why is this?

This seems to be a very local problem.
You may want to check if the spelling in all fields is exactly the same for all files in respect to the metadata that renames the folders.
I still wonder, why you do not use the title as data in the filename as you have the albumartist already in the foldername ....
I do not think that it has to do with the similarity between albumartist and album but much more if the case and other spellings are the same between the files.
So, a "Fleetwood Mac" would be different from "FLEETWOOD MAC".

I just tried renaming an album's albumartist to the same name as the album, apart from the case which is different in each, and I'm still getting the problem.

On a related note, one album I'm trying to process comes up with the error that says the file couldn't be renamed because it couldn't find the specified file. I don't know why this is, only that the album name, title AND album artist tags are REALLY LONG - ridiculously long, in fact. I don't know how to proceed.

If you are making changes on names within the filesystem (filename, foldername) ...
as you are doing so, ... then you have to make sure not to use forbidden characters.
Apply ... function $validate ...

$validate(%ALBUMARTIST%'\'%ALBUM%'\'$num(%DISCNUMBER%,1)' '$num(%TRACK%,2)' '%ALBUMARTIST%,'_') ... or ... $validate(%ALBUMARTIST%'\'%ALBUM%'\'$num(%DISCNUMBER%,1)' '$num(%TRACK%,2)' '%ALBUMARTIST%,)


Tried your scripts, DetLevD, still kept saying files had been renamed no matter how often I ran the script and refreshed.

I've also discovered that if I apply JUST the disc and track numbers in the filename (nothing else), then that album I mentioned with the very long tags will rename just fine.

There is a method which can help against too long filepathnames ...
Help with smart truncating of long filenames


It looks like as the status message will be triggered in all cases when the entire filepathname has been touched and folders has been renamed or created.


I'm going to try this script for Tag > Filename:

The two albums that I mentioned that didn't work with the previous script DO work with this one, it seems. What's more, I prefer the album artist AND the album to be in the same single folder as I had before, and I use album artist for the tracks as well, as I don't tend to use the file mode in players.

The only thing I found I had to do was to limit the length of all the various strings, and I like to trim strings as well.

Also, I have to ask, what use is $validate when it seems that all illegal characters for filenames are filtered out when Alt-F1 is used anyway? I gave a random album illegal characters like "/" and ran the first script without $validate and the "/" was filtered out in any case.

I do not understand what you mean with ...
"filtered out when Alt-F1 is used anyway", ... please explain.

The following characters are not allowed to be used within a filename ...
... but Mp3tag's dialog "Tag - Filename" does not remove all these characters.
For example ... Mp3tag accepts the backslash as a valid character for the filename.

Further on ...
... creates a preview of ...
########e a.mp3
... which is a rather weird filename ...
and it demonstrates, that the function $validate does not validate all forbidden characters.

About invalid characters look there ...
[F] $validate() broken?

I do not believe that Mp3tag accepts the / slash character as part of the filename.
Try it out in Mp3tag Listview column to insert a slash into the filename, ...
then you will receive an error message.

The / slash character is not registered as an invalid path character ...
it is the valid path separator on Apple Mac and UNIX systems and also used for web addresses, ...
and for example, ...
someone can use the slash character as the path separator within the Explorer address line.


$validate() lets you set the character that is used as a replacement for an illegal character. Naturally, it is not possible to create illegal filenames. The OS would not allow it.
But as the illegal characters are simply cut out, this might not suit your requirements, so you can set that you get an indication that there would have been an illegal character.

When I said the above, I meant that I took a random MP3 album and changed the "album" tag in all the tracks so that it had a "/" at the end of it, and when I ran the Alt-1 script I mentioned before, the "/" was filtered out. Sorry for the confusion.

Thanks for the explanation, Ohrenkino, although I know from personal experience about illegal characters, from Windows itself telling me when I make a typo during filename entry to my own research when I was developing filename-dependent applications.

I think I ought to explain why I put the album artist into the album tracks in the filenames when I use Alt-1: this is simply because I create my own albums out of my own recordings some of the time, and during the process I might want to edit my title tags as I make corrections, and put simply, it's a lot easier to not use the title tags (as the album artist tag is much less likely to change) so I don't have to Alt-1 the album each time.

In any case, I see the folders and files as mere placeholders for the REAL core of the MP3 audio and tags, which are much less unlimited in the characters the tags use, and they can be much longer anyway. And it's what most users see on media players. I see no advantage to "Folder Mode" on any such player.

You are quite right: the filename is only a surrogate for the real data. There are numerous limitations for filenames, so in general, the only rule there is: they have to comply with the rules of the file system but are void in respect to data keeping.
Yet, it may sometimes be fairly useful to get a hint what a particular file is about without having to start the respective presentation program. Usually, with other files for other applications like word processing or spread sheets, one uses a filename that gives a summary of the contents.
The naming scheme relies mainly on the individual requirements and may differ from (personal) environment to environment.

After much trial and error, I finally found that this script for Tag>Filename works just fine with every album I threw at it:

$trim($left(%albumartist%,40))  $trim($left(%album%,40))\$num(%discnumber%,1) $num(%track%,2)  $trim($left(%title%,40))

And I've finally converted my whole collection this way, which should make things easier. And yes, I decided on titles for the tracks, just to make it friendlier for Folder Mode in media players.

Thanks for the info!