DirectoryName

DirectoryName["name"]

extracts the directory name from the specification for a file.

Details and Options

Examples

open allclose all

Basic Examples  (1)

Get the directory name of a file on Windows:

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

Get the directory name of a file on Mac OS X:

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

Apply DirectoryName two times:

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

Scope  (1)

See Also

Directory  ParentDirectory  SetDirectory  FileBaseName  FileNameJoin  $Path  $PathnameSeparator  $Input  $InputFileName  NotebookDirectory

Tutorials

Introduced in 1996
(3.0)
| Updated in 2016
(11.0)