ExpandFileName

ExpandFileName["name"]

textually expands name to have the form of an absolute file name for your operating system.

Details

  • ExpandFileName["name"] interprets name relative to your current directory.
  • ExpandFileName expands directory designations such as . and ...
  • The result from ExpandFileName has the form of an absolute file name, with standard pathname separators appropriate for your operating system.
  • ExpandFileName just operates on names of files; it does not actually search for the file specified.
  • ExpandFileName[File["name"]] is also supported.
  • ExpandFileName[URL["file:///path"]] converts a file-based URL to an absolute file name.

Examples

open all close all

Basic Examples  (3)

Convert the relative directory path to the full name:

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

Reset the directory to the previous directory:

In[3]:=
Click for copyable input

Expand the file name specified by the File object:

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

Convert a file scheme URL to an absolute path:

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

Applications  (1)

Introduced in 2008
(7.0)
|
Updated in 2019
(12.0)