9
$\begingroup$

What command within a notebook will return the file name of that notebook?

$\endgroup$
11
$\begingroup$

You have to add a few extra commands to NotebookFileName to remove the directory.

Last@FileNameSplit@NotebookFileName[]

Hope this helps.

$\endgroup$
  • 5
    $\begingroup$ if you don't need the extension you can do it even shorter: FileBaseName@NotebookFileName[]. If you know the extension is .nb then (FileBaseName@NotebookFileName[])<>".nb" $\endgroup$ – yohbs Jul 19 '15 at 11:30
10
$\begingroup$

No need to go through all the machinations of trimming/applying a cascade of functions, simply:

CurrentValue["NotebookFileName"]
$\endgroup$

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.