Filename Character Length Limit...

Discussion in 'OS X Yosemite (10.10)' started by JoelBC, Dec 8, 2014.

  1. JoelBC macrumors 6502a

    Joined:
    Jun 16, 2012
    #1
    Is there a limit to the number of characters in a filename and, if yes:

    1. What is the limit in HFS format [i.e. Macintosh HD:User:Documents:...]?

    2. What is the limit in POSIX format [i.e. ~/Users/Documents/...]?

    3. Which is better / preferred in terms of the ability to transfer file between devices so that files are not missed [i.e. not copied / not moved] because their filename length is too long?

    Thanks in advance,

    Joel
     
  2. maflynn Moderator

    maflynn

    Staff Member

    Joined:
    May 3, 2009
    Location:
    Boston
    #2
    Searching the google, I easily came up with 255 characters for bot HFS+ POSIX file formats.

    I'd say the best one is native file format for OS X, that is HFS+ is better for OSX.
     
  3. NoBoMac macrumors 6502a

    Joined:
    Jul 1, 2014
    #3
    Don't forget to add into the equation the length of a pathname, which is 1024 in OS X (and generally most *nix boxes).

    Sure, can have folders and files with 255 chars, but that limits number of sub-folders possible.

    "Strict" POSIX is 14 characters for files, 256 for paths, but doubt one will see something setup like that in this day and age.

    Code:
    $ getconf _POSIX_NAME_MAX
    14
    $ getconf _POSIX_PATH_MAX
    256
    $ getconf _XOPEN_NAME_MAX
    255
    $ getconf _XOPEN_PATH_MAX
    1024
    
     
  4. Partron22, Dec 8, 2014
    Last edited: Dec 8, 2014

    Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #4
    I got the same answer easily by renaming a file in Finder; just keep typing until it beeps at you, then paste the result into BBEdit to get a character count.
    Any extension e.g. .jpg, counts toward the limit.

    HFS limit used to be 31 characters.
    HFS+ limit is 255-character unicode file names
     
  5. JoelBC thread starter macrumors 6502a

    Joined:
    Jun 16, 2012
    #5
    Appreciate all the responses...so, to summarize to make sure I have this right:

    1. HFS+ Format...the limit is 255 characters which starts with "Macintosh HD" and ends with the filename extension [i.e. .doc]. Is this correct.

    2. POSIX Format...the limit is 255 characters which starts with "User" [i.e. as is User/UserName/Documents/test_file.doc] and ends with the file extension.


    If this is not correct then please correct.

    One last thing, why it is better to count / work in than in POSIX?

    Thanks.
     
  6. NoBoMac macrumors 6502a

    Joined:
    Jul 1, 2014
    #6
    Re: lengths. No, you have it wrong. Maybe I'm miss reading the post.

    255 for individual file/folder name, with the path being a total of 1024 characters, with all the "/" and path prefix to a given file.

    So, can build a path/structure:

    /Users/myusername/<255charfoldername>/<255filenamewith.ext>

    This would be a 529 character pathname with two 255 "files" (folders are really files in *nix world).
     
  7. JoelBC thread starter macrumors 6502a

    Joined:
    Jun 16, 2012
    #7
    Appreciate the clarification which I know understand subject to the following:

    1. Please confirm that the pathname DOES INCLUDE the "/" in "/Users'.

    2. Please confirm that the "/" before either the folder name or filename count as part of the pathname but do not count as part of the filename.

    Thx..
     

Share This Page