ParentDirectory

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

Examples

open allclose all

Basic Examples  (3)

Get the parent directory of the current working directory:

In[1]:=
Click for copyable input
Out[1]=

Verify the answer:

In[2]:=
Click for copyable input
Out[2]=

Get the parent of $InstallationDirectory:

In[1]:=
Click for copyable input
Out[1]=

Find the grandparent of $InstallationDirectory:

In[1]:=
Click for copyable input
Out[1]=

Scope  (3)

Properties & Relations  (4)

See Also

Directory  $HomeDirectory  DirectoryName  FileNameDrop

Tutorials

Introduced in 1991
(2.0)
| Updated in 2017
(11.2)