Windows 7 file name length limited to 129 characters

18

9

I'm trying to properly name MP3s and I hit some arbitrary length of 129 characters (not 128?). NTFS supports 255 characters in file names, how do I fix this?

Star Wars - 6 - Return of the Jedi - 2 - 07 - Battle of Endor 2, Leia Is Wounded, The Duel Begins, Overtaking Bunker, Dark Si.mp3

John

Posted 2014-09-13T03:50:39.893

Reputation: 1 490

2It is better not to rely on really long filenames as this can lead to a number of problems. MP3s can have embedded metadata in the form of ID3 tags for this and/or use directories. – JamesRyan – 2014-09-14T11:01:10.877

3I open files and playlists; I do not use "media libraries". My collections are properly named, I don't have any "1.mp3" files and can't stand people too lazy to properly name files; which "1.mp3" when every album has at least one track. ಠ_ಠ – John – 2014-09-14T11:12:07.490

Answers

13

It is possible that you are exceeding a total of 260 characters for the entire pathname, including the backslash characters.

How many characters are in the path, including the name of the mp3 file?

David Paige

Posted 2014-09-13T03:50:39.893

Reputation: 309

1Yeah, turns out renaming the files on the drive without directories allows longer names. Pretty lame that the file name and paths are counted together and not separate. – John – 2014-09-13T04:34:26.870

5the MAX_PATH constant is defined to be 260, not 256 – phuclv – 2014-09-13T04:43:55.740

Folders though, have only a max of "247 char + <null>". See http://stackoverflow.com/a/15971467/632951

– Pacerier – 2015-08-18T06:16:35.653

34

In Windows the default total path length must not exceed 260 characters (drive + :\ + 255 characters of filename + null terminator + probably for final \ in case the path is a directory or simply for even rounding). It was a relic from DOS's 8.3-name era where a 260-character path is a really deep path.

It's possible that your path to the folder was already very long, so the remaining part for your filename is just 129. If you want longer path, you have several solutions:

Since Windows 10 there's another option by removing MAX_PATH limitation§. You can enable it by setting HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled in registry or set Computer Configuration > Administrative Templates > System > Filesystem > Enable NTFS long paths in group policy


Read more:

The maximum path of 32,767 characters is approximate, because the \\?\ prefix may be expanded to a longer string by the system at run time, and this expansion applies to the total length.

§Starting in Windows 10, version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behavior.

phuclv

Posted 2014-09-13T03:50:39.893

Reputation: 14 930

Thanks, David posted first and it worked, but you included resources so +1. – John – 2014-09-13T04:40:05.893

1

A similar solution is to use a junction. Check out http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html

– Urhixidur – 2014-09-13T11:54:54.057

1I'd rather use this answer, too. That way, you can keep your files where you want, and still be able to name them the way you'd like to. Plus, when you copy them to your device, it's most likely not going to care about the silly Windows limitation, as they have a very flat file hierarchy, and may not even use the file name directly (e.g. iPhone/iPad/iEtc uses hex characters for file names, and cross-references an index file). – phyrfox – 2014-09-13T23:43:47.707

The maximum number of characters for a filename is 255 characters, not 256 – Edd – 2015-06-17T14:58:58.557

@Edd 255 characters + null termination – phuclv – 2015-06-17T16:14:41.227

@LưuVĩnhPhúc no, null termination forms part of the limit on the path, not the filename – Edd – 2015-06-18T10:40:06.490

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx the more correct way to descbibe it is "the maximum path on drive D is "D:\some 256-character path string<NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage" – phuclv – 2015-06-18T11:21:36.927

@LưuVĩnhPhúc, Is "drive" guaranteed to be only one character long? – Pacerier – 2015-08-18T05:16:58.680

@Pacerier yes. In Windows only 26 drive letters are allowed. If you want to use more than that you must mount under another NTFS folder – phuclv – 2015-08-18T05:26:45.607

0

Windows 7 will allow you to save filenames longer than 256 characters including path names and they can be accessed easily as well. The only small difficulty you may run into is when you copy them from one place to another, but you will be presented with a popup that asks you if you want to change the filename, not copy the file, or save it as is. I always save it as is and I've never had any problems. I've probably got a couple of hundred filenames that exceed the limit.

Gruff

Posted 2014-09-13T03:50:39.893

Reputation: 1

no, it won't allow you to save files longer than 255 characters since that's the file system limit – phuclv – 2018-08-20T00:34:59.723

the path, however, can be slightly longer (or much longer after removing MAX_PATH limitation) – phuclv – 2019-05-29T01:19:21.160