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?
$\begingroup$
$\endgroup$
3
1 Answer
$\begingroup$
$\endgroup$
0
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"}]
AbsoluteOptions[EvaluationNotebook[], WindowTitle]
? $\endgroup$NotebookFileName[EvaluationNotebook[]]
$\endgroup$