FileNameDepth

FileNameDepth["name"]

gives the number of path elements in the file name "file".

Details and Options

  • FileNameDepth["a/b/c"] gives 3.
  • FileNameDepth by default assumes pathname separators and other conventions suitable for your operating system.
  • FileNameDepth[,OperatingSystem->"os"] uses the conventions of the specified operating system. Possible choices are "Windows", "MacOSX", and "Unix".
  • FileNameDepth just operates on names of files; it does not actually search for the file specified.
  • FileNameDepth[File["name"]] is also supported.

Examples

open allclose all

Basic Examples  (3)

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

File name depths of some standard directories:

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

Scope  (1)

Find the number of path elements in the file name specified by the File object:

Wolfram Research (2008), FileNameDepth, Wolfram Language function, https://reference.wolfram.com/language/ref/FileNameDepth.html (updated 2016).

Text

Wolfram Research (2008), FileNameDepth, Wolfram Language function, https://reference.wolfram.com/language/ref/FileNameDepth.html (updated 2016).

CMS

Wolfram Language. 2008. "FileNameDepth." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/FileNameDepth.html.

APA

Wolfram Language. (2008). FileNameDepth. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileNameDepth.html

BibTeX

@misc{reference.wolfram_2024_filenamedepth, author="Wolfram Research", title="{FileNameDepth}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/FileNameDepth.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_filenamedepth, organization={Wolfram Research}, title={FileNameDepth}, year={2016}, url={https://reference.wolfram.com/language/ref/FileNameDepth.html}, note=[Accessed: 21-November-2024 ]}