({{, (RefLink[NotebookDirectory, paclet:ref/NotebookDirectory])[]
gives the directory of the current evaluation notebook. }, {, (RefLink[NotebookDirectory, paclet:ref/NotebookDirectory])[nb]
gives the directory for the notebook specified by nb. }})

OpenersNotesSection(Spacer1)Details

(RefLink[NotebookDirectory, paclet:ref/NotebookDirectory]) returns the full name of the directory as a string.

(RefLink[NotebookDirectory, paclet:ref/NotebookDirectory]) gives (RefLink[$Failed, paclet:ref/$Failed]) if the specified notebook has never been saved as a file.

The directory given by (RefLink[NotebookDirectory, paclet:ref/NotebookDirectory]) is on the filesystem of the computer on which the notebook front end is being run.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Find the name of the directory containing the notebook file for this reference page:

NotebookDirectory[]

OpenersExampleSection1(Spacer1)Possible Issues  (2)

There is no directory for a notebook that has been created but not yet saved:

nb=CreateDocument[{x,y,z}]

NotebookDirectory[nb]

If an evaluation was not directly triggered from within a notebook, there will be no directory:

With[{nb=EvaluationNotebook[]},SessionSubmit[
ScheduledTask[
Paste[nb,ExpressionCell[NotebookDirectory[],"Output"]];TaskRemove[$CurrentTask],{1}]
]];

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[NotebookFileName, paclet:ref/NotebookFileName])  ▪  (RefLink[NotebookInformation, paclet:ref/NotebookInformation])  ▪  (RefLink[Directory, paclet:ref/Directory])  ▪  (RefLink[SetDirectory, paclet:ref/SetDirectory])  ▪  (RefLink[$Input, paclet:ref/$Input])  ▪  (RefLink[$InputFileName, paclet:ref/$InputFileName])  ▪  (RefLink[FindFile, paclet:ref/FindFile])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating the Front End from the Kernel, paclet:tutorial/ManipulatingTheFrontEndFromTheKernel])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Directories & Directory Operations, paclet:guide/DirectoriesAndDirectoryOperations])}, {▪(RefLinkPlain[Operations on File Names, paclet:guide/OperationsOnFileNames])}, {▪(RefLinkPlain[Low-Level Notebook Programming, paclet:guide/LowLevelNotebookProgramming])}})}})