Automate filename cutting for more than 259 chars in an elegant way?


Hi guys

As far as I have checked, with W7 64 and most apps there's a length limit for the full path of a file of 259 chars. Due to my folder organization, sometimes I need to "cut" actual filenames, adding something like [...] at the end. Something like:

Penderecki - Concerto Grosso No. 1 for 3 Cellos - I - Andan[...].flac

Currently Mp3tag allows me to know how many chars my original name is exceeding from the limit, with a custom column like this.

$iflonger(%_path%,259,ERROR '('$sub($len(%_path%),259)')',OK '('$sub(259,$len(%_path%))')')

I can then manually cut the filename in explorer, which is a bit boring when you have hundreds of files like this, or you change your folder structure and more files need to be cut.

It would be nice to automate the filename cutting, but, since Mp3tag has that limit of 259, it doesn't allow me to modify anything from the path-too-long files, just read. If I move those files to a root folder so they can be modified, then Mp3tag can't know who the bad guys are...Currently I have a method in mind with two stages, but is fairly poor:

1-Export a text file (Mp3tag has no problem in reading long-path files) with the new filenames, whenever they are needed.
2-Move the whole folders to a root directory, use the previous file to adjust filenames and move back to original folder.

Any ideas of how to modify a filename with a shorter one wihout all that crap? I think that it could be of general interest for Classical Music fans, since long names are common, and quite useful.

My apologies for the extensions, hope I could get some help. Thanks in advance!


I think that this is a limitation of the filesystem and not mp3tag.

Anyway: you could create a user-defined field that has as content the path including the filename.
Then check if that field is longer than allowed and then apply a cutleft to the that user-defined field and perhaps a little more to add a $num(%track%,2) at the end to get an unambiguous filename.
Then use the content of the user-defined field as source for the filename.


I'm sorry, I can't answer your original question. However, I doubt that these long names are useful, so, if you like, you could explain more detailed why your paths are so long and the community might come up with ideas how to shorten them inherently ;-).

Because of Comments/Tags (and the ability of explorer and the like to read them) it is not necessary to put the whole information redundantly into the path, IMHO.


I too would love a fix for this, and have yet to find a solution :frowning:


Ahh, now I know what you mean. If you create a directory on the root of your drive with the name C:\Test with a extremely long directory name who never ends and I dont know what I could write else in this directory therefore I repeat Test with a extremely long directory name who never ends never ends never ends never ends never ends1234567890 and the 4 subdirectories \A

      \D I learned, that the longest number for such a directory construction is around 256 (not exactly, because it depends on how you create it and which subdirectory level you try to extend).

You could try something like this:
Format string: $iflonger(%_folderpath%,232,$left(%_filename%,24),%_filename%)
FIRST WARNING: This would cut your existing filename down to 24 characters, if your _folderpath is longer then 232 character. You have to adjust this two numbers to your existing structure and needs!
SECOND WARNING: I don't believe that you get meaningful filenames if you let a computer cut them after a specific number of characters. Possible example:
OLD: 01 - Here Are Many Wild Animals.mp3
CUT: 01 - Here.mp3

This is only an example how it would technically work... Be EXTREMELY careful! :ph34r:


The magic is ... "first virtual, then real"

Find there something of interest ...



OP can try this elegant way ...

Action: Format value
Format string: $regexp(%_filename%,'[[:space:][:lower:][:punct:]]',)

... but there is a good chance to get duplicate filenames.