NotebookFileName

NotebookFileName[]
gives the file name of the current evaluation notebook.

NotebookFileName[nb]
gives the file name for the notebook specified by nb.

DetailsDetails

  • 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.

ExamplesExamplesopen allclose all

Basic Examples  (1)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
Introduced in 2008
(7.0)