Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
4  
AbsoluteOptions[EvaluationNotebook[], WindowTitle] ? –  Kuba Sep 16 '13 at 11:49
6  
or if it is saved (is it?): NotebookFileName[EvaluationNotebook[]] –  Pinguin Dirk Sep 16 '13 at 11:49
    
The notebook is indeed saved, that was precisely what I was searching for... Thanks, once again! –  Gabriel Sep 16 '13 at 14:21
add comment

1 Answer

up vote 14 down vote accepted

If the notebook is saved, you can use:

NotebookFileName[EvaluationNotebook[]]

or simply (thanks to @rm -rf)

NotebookFileName[]

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

NotebookFileName[] // FileNameSplit // Last

Alternatively, even for unsaved notebooks, try:

CurrentValue[EvaluationNotebook[], {"NotebookFileName"}]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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