2
$\begingroup$

There may be many ways to distinguish .nb that has been saved from new .nb

I found that in NotebookInformation[] may be useful.

It seems for .nb that has been saved, NotebookInformation[] start with

"FileName"

enter image description here

Whereas for new .nb, there is no "FileName" part.

enter image description here

From the experts' point of view, this may be inaccurate sometimes, or didn't considered rare, special cases. (Hyperlink or Cloud related, etc...)

If there is a better way than this(or equally good), please introduce it.

$\endgroup$

1 Answer 1

5
$\begingroup$
Quiet@NotebookFileName[]

returns name of current notebook in the case it was saved

or

$Failed in the case it was never saved.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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