ParentDirectory
✖
ParentDirectory
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 allclose allBasic Examples (3)Summary of the most common use cases
Get the parent directory of the current working directory:

https://wolfram.com/xid/05fj3pxg82-ghw2pm


https://wolfram.com/xid/05fj3pxg82-j29ncm

Get the parent of $InstallationDirectory:

https://wolfram.com/xid/05fj3pxg82-imcutg

Find the grandparent of $InstallationDirectory:

https://wolfram.com/xid/05fj3pxg82-h14u7k

Scope (3)Survey of the scope of standard use cases
Get the parent directory of the directory specified by the File object:

https://wolfram.com/xid/05fj3pxg82-bzvdwh

Go up two levels from the same location:

https://wolfram.com/xid/05fj3pxg82-c03ce0

Go up two levels from the current directory:

https://wolfram.com/xid/05fj3pxg82-fdbe54

Compare with the current directory:

https://wolfram.com/xid/05fj3pxg82-yg8yrz

Explicitly request the directory one level higher than the current directory:

https://wolfram.com/xid/05fj3pxg82-uqhpl0

This is equivalent to the following:

https://wolfram.com/xid/05fj3pxg82-078egc

Properties & Relations (4)Properties of the function, and connections to other functions
In ParentDirectory[dir], dir must exist as a directory:

https://wolfram.com/xid/05fj3pxg82-duejxj


ParentDirectory always returns a full path:

https://wolfram.com/xid/05fj3pxg82-hoyz8d

ParentDirectory[1] is equivalent to ParentDirectory[]:

https://wolfram.com/xid/05fj3pxg82-2zs07u

ParentDirectory operates only on existing directories and returns a full path:

https://wolfram.com/xid/05fj3pxg82-rhvs0s

FileNameDrop performs a similar path operation but at a purely textual level:

https://wolfram.com/xid/05fj3pxg82-wvjhrt

Wolfram Research (1991), ParentDirectory, Wolfram Language function, https://reference.wolfram.com/language/ref/ParentDirectory.html (updated 2017).
Text
Wolfram Research (1991), ParentDirectory, Wolfram Language function, https://reference.wolfram.com/language/ref/ParentDirectory.html (updated 2017).
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.
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
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: 10-July-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: 10-July-2025
]}