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

  • 2
    It 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 Sep 14 '14 at 11:01
  • 3
    I 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 Sep 14 '14 at 11:12

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?

  • 1
    Yeah, 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 Sep 13 '14 at 4:34
  • 5
    the MAX_PATH constant is defined to be 260, not 256 – phuclv Sep 13 '14 at 4:43
  • 1
    Folders though, have only a max of "247 char + <null>". See stackoverflow.com/a/15971467/632951 – Pacerier Aug 18 '15 at 6:16
  • You are incorrect re maximum size of a path. It is less than you think. See pastebin.com/raw/Xcg7Wndc and C:\t>md "a_243char_ijbcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabhcdefghijabcdefghijabcdefghbijabccdghij_243char_hi" <-- The filename or extension is too long. – barlop Apr 29 '20 at 8:26

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.

  • Thanks, David posted first and it worked, but you included resources so +1. – John Sep 13 '14 at 4:40
  • 1
    A similar solution is to use a junction. Check out schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html – Urhixidur Sep 13 '14 at 11:54
  • 1
    I'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 Sep 13 '14 at 23:43
  • The maximum number of characters for a filename is 255 characters, not 256 – Edd Jun 17 '15 at 14:58
  • @Edd 255 characters + null termination – phuclv Jun 17 '15 at 16:14

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.

  • no, it won't allow you to save files longer than 255 characters since that's the file system limit – phuclv Aug 20 '18 at 0:34
  • the path, however, can be slightly longer (or much longer after removing MAX_PATH limitation) – phuclv May 29 '19 at 1:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.