I've searched the documentation, this forum and with google, but I was not able to find how to ask Mathematica to give back the name of the current notebook file one is working on. Perhaps something with EvaluationNotebook[], but that gives a NotebookObject. How is it possible to use this information to retain just the filename?

  • 4
    $\begingroup$ AbsoluteOptions[EvaluationNotebook[], WindowTitle] ? $\endgroup$ – Kuba Sep 16 '13 at 11:49
  • 6
    $\begingroup$ or if it is saved (is it?): NotebookFileName[EvaluationNotebook[]] $\endgroup$ – Pinguin Dirk Sep 16 '13 at 11:49
  • $\begingroup$ The notebook is indeed saved, that was precisely what I was searching for... Thanks, once again! $\endgroup$ – Gabriel Sep 16 '13 at 14:21

If the notebook is saved, you can use:


or simply (thanks to @rm -rf)


and if it's just the file's name you are after:

NotebookFileName[] // FileNameSplit // Last

Alternatively, even for unsaved notebooks, try:

CurrentValue[EvaluationNotebook[], {"NotebookFileName"}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.