Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Number of folder sub-levels and characters

Does anyone know:
a) how many levels of folders are permissible in Mac OS X
b) how many characters are allowed for file or folder names?

I have recently switched over to the Mac system from Windows where the I believe the maximum number of "folders within folders" (levels in the hierarchy) is 8, and the maximum number of characters for naming files or folders is 64. My main concern is that backups in Windows are truncated beyond these limits.

I've searched for answers in Apple tutorials, forums, books (etc.), and even AppleCare was not able to answer these questions.

Thank you very much!

MacBook Pro, Mac OS X (10.6.4)

Posted on Oct 1, 2010 3:59 PM

Reply
Question marked as Best reply

Posted on Oct 1, 2010 4:07 PM

how many levels of folders are permissible in Mac OS X


Any.

how many characters are allowed for file or folder names?


255.

(54098)
11 replies

Oct 4, 2010 10:41 AM in response to Richology

Thank you. Surprising that there is absolutely no limit on the number of folder levels and greatly appreciate the specific 255 characters information.

There is a path length of 1024 as specified by the pathconf() function:

PC_PATHMAX == 1024

What this means is if you are going to pass a path to a kernel function (and many library routines), the total string length may not exceed 1024 characters.

However, if you do something like

mkdir a
cd a
mkdir b
cd b
mkdir c
cd c
mkdir d
cd d
etc...

you can continue as deep as you wish, you will just need to make sure that when you access any files at the deeper levels that the string specified as the path does not exceed 1024 bytes.

Oct 4, 2010 11:09 AM in response to BobHarris

Thank you, Bob. You hit my concern exactly where you indicated: "... you will just need to make sure that when you access any files at the deeper levels that the string specified as the path does not exceed 1024 bytes."

Since this is "cumulative," is there any way to know when the limit has been exceeded before running into any issues down the road?

For example, in Windows, when this limit was exceeded, that data was was truncated when attempting to backup or even just "copy and paste" to another drive.

Oct 4, 2010 11:40 AM in response to Richology

While not 100%, many backup utilities, internally cd to the current directory as they walk down the directory tree, so they are only opening the filename and do not need to specify a path, or at worse specify the path as ./filename

Your mileage may vary.

It is actually a good idea to NOT create extremely long paths.
Since this is "cumulative," is there any way to know when the limit has been exceeded before running into any issues down the road?

If you are using a program that actually specifies the full path via a path string, then it will either get a file or directory not found as the path is too long, or the function will return an error if it checks the path length, or if you are unluckly, it will stop processing the long path at an exact point that happens to match a real file.

This is all on a program by program basis.

Oct 4, 2010 6:40 PM in response to Whitecity

Dear Whitecity, regarding your question: "Out of interest, what are you doing that would cause you to worry about this?"

My concern is only what I mentioned above, that with the Windows OS, there are limits with the number of sub-levels. If those are exceeded, subsequent information is truncated during backups or even when copying information between disks. It's not always apparent during day-to-day usage, since there are no warnings about that if you happen to add a folder beyond that level. It becomes an issue when accessing a backup and finding that certain information is not available. Being new to OS X, I wanted to make sure I took that into account if there was any sort of similar limit.

Number of folder sub-levels and characters

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.