NotebookFileName

NotebookFileName[]

gives the file name of the current evaluation notebook.

NotebookFileName[nb]

gives the file name for the notebook specified by nb.

Details

  • NotebookFileName returns the absolute file name for the notebook as a string.
  • NotebookFileName gives $Failed if the specified notebook has never been saved as a file.
  • The file name given by NotebookFileName is on the filesystem of the computer on which the notebook front end is being run.

Examples

Basic Examples  (1)

Create a notebook, save it in a file, and then open it:

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

Find the file name for the notebook:

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

Close the notebook and delete the file:

In[4]:=
Click for copyable input
In[5]:=
Click for copyable input

See Also

NotebookDirectory  $Input  $InputFileName  FileNameSplit

Introduced in 2008
(7.0)