({{, (RefLink[FileNameDepth, paclet:ref/FileNameDepth])["name"] 
gives the number of path elements in the file name "file".}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[FileNameDepth, paclet:ref/FileNameDepth])["a/b/c"] gives 3.

(RefLink[FileNameDepth, paclet:ref/FileNameDepth]) by default assumes pathname separators and other conventions suitable for your operating system.

(RefLink[FileNameDepth, paclet:ref/FileNameDepth])[…,(RefLink[OperatingSystem, paclet:ref/OperatingSystem])->"os"] uses the conventions of the specified operating system. Possible choices are "Windows", "MacOSX", and "Unix".

(RefLink[FileNameDepth, paclet:ref/FileNameDepth]) just operates on names of files; it does not actually search for the file specified.

(RefLink[FileNameDepth, paclet:ref/FileNameDepth])[(RefLink[File, paclet:ref/File])["name"]] is also supported.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Find the number of path elements that make up a file name:

FileNameJoin[{"a","b","c"}]

FileNameDepth[%]

File name depths of some standard directories:

FileNameDepth[$RootDirectory]

FileNameDepth[$InstallationDirectory]

FileNameDepth[$UserBaseDirectory]

On Windows, the share name is treated as a single unit:

FileNameDepth["\\\\server\\share\\path\\file"]

FileNameSplit["\\\\server\\share\\path\\file"]

OpenersExampleSection1(Spacer1)Scope  (1)

Find the number of path elements in the file name specified by the (RefLink[File, paclet:ref/File]) object:

FileNameDepth[File[$InstallationDirectory]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FileNameSplit, paclet:ref/FileNameSplit])  ▪  (RefLink[FileNameTake, paclet:ref/FileNameTake])  ▪  (RefLink[StringCount, paclet:ref/StringCount])  ▪  (RefLink[Length, paclet:ref/Length])  ▪  (RefLink[$OperatingSystem, paclet:ref/$OperatingSystem])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Directories & Directory Operations, paclet:guide/DirectoriesAndDirectoryOperations])}, {▪(RefLinkPlain[Operations on File Names, paclet:guide/OperationsOnFileNames])}})}})