what is maximum number of characters allowed in filename?

I asked the question below in another thread, and it perhaps didn't belong there: anyone have any insghts on this?

I use %artist% - %album% - %track% - %title%, or at least try to. I find that Mp3tag occasionally chokes on some files when I try to rename them with this format. The error reported is either that the file could not be found or that the file could not be accessed, but the real issue appears to be that there is a file name length limit. I'm guessing on this, but I have been able to eliminate every occurrence of these errors (about 50 so far) by shortening file names, so I think I'm correct.

I also think there is some kind of limit on the combined total number of characters in the path and file name, because I discovered that the longer the path, the shorter I had to make file names. I think these limits are less than NTFS limits, because I've had problems in Mp3tag and not in Windows Explorer or other Vista functions, and I believe I've always had a path less than NTFS's MAX_PATH limit of 260 characters.

I suggest that Mp3tag be tweaked to check for, and report a clearer error on, file names that are too long either when attempting to convert tag information into filenames, or adding directories. In addition, clarification of the exact limit on file name size and any interaction with filename and path length would be much appreciated.

Read there ...
http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

DD.20100822.2330.CEST

Yes, I read that previously, and I believe I understand what it says about Microsoft's limits. I'm interested in learning details about Mp3tag's limits, because Mp3tag appears to have lower limits.

To put it another way, my experience is that Mp3tag's limits are less than the smallest limit in Microsoft's Windows API environment, which is MAX_PATH less an 8.3 name, which equals 260 - 12, which equals 248. I have many files with combined directory path and filename characters less than 248 characters that Mp3tag forced me to shorten.

I'm no expert in this space, which is why I posted this question, but I would guess that Mp3tag is limited to something like 200 characters or less for the equivalent of MAX_PATH (combined characters of directory path and file name). But I find it likely someone here has far more expertise than me and has more insight on Mp3tag's limit for this. Thanks!

It is always quite difficult to talk about speculation than on facts.
You can find out the truth for yourself by doing a series of tests.
Then inform the forum guests and the developer about the result.

In order to be informed about too long filenames I have opened a new column in Mp3tag list view near the filename column.
The field "value" is filled with this expression ...

$ifgreater($len(%_filename_ext%),64,'!'$len(%_filename_ext%),)

... so it will be automatically obvious when a filename goes over the limit.
I set the limit as the maximal CD filename length of 64 characters.
You can do the same also for the overall length of the entire filepath.

Because the filename is the least important thing in the entire tagging process ("names are sound and smoke"), the 64 character limit is practical useful for me.
The name carries track, title, artist, album, year in a sophisticated abbreviated manner. If I need more textual informations, then I look at the entire filepath structure, and if I need even more details, then I look into the tag fields.

The longest filepath in my collection has 254 characters.

Hmm, I did a short test ... renaming an existing mp3 file in the root of drive F.

Action: Format value
Field: _FILENAME
Formatstring: 'F:'$repeat('A',251)

... gives a filename with entire length of 258 characters.

One more character will lead Mp3tag to display an error message (and later on a somewhat corrupt list entry behind the scene).

You can reach the absolute MAX_PATH size of 260 characters (259 readable characters plus one technical terminating null character) this way ...
Action: Format value
Field: _FILENAME
Formatstring: 'F:\Z'$repeat('A',250)

For that example case there is no file path length limitation by Mp3tag.

This is the same behaviour like Windows XP Explorer application.

258 characters maximal length for a filepathname in the root folder of a disk.

259 characters maximal length for a filepathname in a subfolder of a disk.

(I want to mention, that I am stumbled over a quirk or bug in Mp3tag which gives an erroneous error message and displays an erroneous content by the system variable %_path%. Mp3tag needs to be restarted. When I am able to repeat this situation step by step I will come back and report.)

DD.20100823.0816.CEST

Next round.

Having a filename: 1.mp3 (length=5)
Action: Format value
Field: _DIRECTORY
Formatstring: 'F:'$repeat('1234567890',24)'\1234' (length=249)

Entire file path is (3 + 240 + 6) + 5 = 254 chars, is less than 260.
Mp3tag does not complain and displays a status message "0 of 1 files ...", no change in filesystem.

Having a filename: 1.mp3 (length=5)
Action: Format value
Field: _DIRECTORY
Formatstring: 'F:'$repeat('1234567890',24)'\123' (length=248)

Entire file path is (3 + 240 + 5) + 5 = 253 chars, is less than 260.
Mp3tag displays a status message "0 of 1 files ..." and made the change in the filesystem!

Result: 248 chars is the maximum length for the path component of the entire filepath.
This sounds to be consistent with the MSDN article.
When using an API to create a directory, the specified path cannot be so long that you cannot append an 8.3 file name (that is, the directory name cannot exceed MAX_PATH minus 12).
The equation is: 260 - 1 - 8 - 3 = 248.

DD.20100823.1818.CEST

Next round.

Having a filename: 12345678.mp3 (length=12)
Action: Format value
Field: _DIRECTORY
Formatstring: 'F:'$repeat('1234567890',24)'\123' (length=248)

Entire file path is (3 + 240 + 5) + 12 = 260 chars, is equal to 260.
Mp3tag displays an error message "12345678 cannot be moved ... too long ... cannot be accessed ..."

Result: 260 chars are not allowed.
This sounds not to be consistent with the MSDN article, which tell us about free space for a 8.3 filename.

Having a filename: 1234567.mp3 (length=11)
Action: Format value
Field: _DIRECTORY
Formatstring: 'F:'$repeat('1234567890',24)'\123' (length=248)

Entire file path is (3 + 240 + 5) + 11 = 259 chars, is one less than 260.
Mp3tag displays a status message "0 of 1 files ..." and made the change in the filesystem!

Result: 259 chars is the maximum length for the entire filepath.
This sounds not to be consistent with the MSDN article, because there is in fact no free space for a 8.3 filename!

Anyway there seems to be a difference by one char.
Is it a simple documentation error?
Is it the terminating null char?
Forgot one backslash path delimiter?

DD.20100823.1845.CEST

Excellent suggestions on how to figure this out. I can also report that I hit a limit of 259 characters - I could save a file with 259 characters in the path and file name combined, but not 260. That would be close enough for me - I'm more interested in knowing the limit so I can deal with it. I do find this result different that what I recall from previous efforts, but shame on me for not looking into it in a more disciplined manner before.

I would still prefer a more plainly-stated error message if a file name is too long, but I created a dummy file of exactly 259 characters (name and path) in my master folder, so based on column width and a visual scrolling check I can quickly figure out which new file names are too long after I use tag info to create my file name.

As always, I'm very impressed with this application and the support users receive in the forums. Thanks again!

The visual comparing of text length can work fully satisfying only when a fixed pitch font is used like "Courier", but this is not possible in Mp3tag yet, because Mp3tag has no option to change font type within it's application.

I prefer the method described above in post #4. Create a column in Mp3tag list view and use an scripting expression, which calculates the length and returns a message when the given limit is exceeded.

DD.20100830.1056.CEST