gives the parent of the current working directory.
ParentDirectory["dir"]
gives the parent of the directory dir.
ParentDirectory["dir",n]
gives the directory n levels up from dir.


ParentDirectory
gives the parent of the current working directory.
ParentDirectory["dir"]
gives the parent of the directory dir.
ParentDirectory["dir",n]
gives the directory n levels up from dir.
Details

- ParentDirectory returns the full name of the directory as a string.
- If n is an integer, ParentDirectory[n] gives the directory n levels up from the current directory.
- ParentDirectory[File["dir"],…] is also supported.
Examples
open all close allBasic Examples (3)
Get the parent directory of the current working directory:
Get the parent of $InstallationDirectory:
Find the grandparent of $InstallationDirectory:
Scope (3)
Get the parent directory of the directory specified by the File object:
Go up two levels from the same location:
Go up two levels from the current directory:
Compare with the current directory:
Explicitly request the directory one level higher than the current directory:
Properties & Relations (4)
In ParentDirectory[dir], dir must exist as a directory:

ParentDirectory always returns a full path:
ParentDirectory[1] is equivalent to ParentDirectory[]:
ParentDirectory operates only on existing directories and returns a full path:
FileNameDrop performs a similar path operation but at a purely textual level:
See Also
Tech Notes
Related Guides
Related Workflows
- Construct a File Path Programmatically
History
Introduced in 1991 (2.0) | Updated in 2016 (11.0) ▪ 2017 (11.2)
Text
Wolfram Research (1991), ParentDirectory, Wolfram Language function, https://reference.wolfram.com/language/ref/ParentDirectory.html (updated 2017).
CMS
Wolfram Language. 1991. "ParentDirectory." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/ParentDirectory.html.
APA
Wolfram Language. (1991). ParentDirectory. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ParentDirectory.html
BibTeX
@misc{reference.wolfram_2025_parentdirectory, author="Wolfram Research", title="{ParentDirectory}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ParentDirectory.html}", note=[Accessed: 13-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_parentdirectory, organization={Wolfram Research}, title={ParentDirectory}, year={2017}, url={https://reference.wolfram.com/language/ref/ParentDirectory.html}, note=[Accessed: 13-August-2025]}