# How to load a file in a directory inside the current working directory

How can I use something like that

 NotebookEvaluate[
"Mathematica\\SomeFile.nb"];


 NotebookEvaluate[
"B:\\Users\\icemt_000\\Documents\\Mathematica\\SomeFile.nb"];


where Directory[] is set to "B:\\Users\\icemt_000\\Documents"?

I think it should just work, but if not use

NotebookEvaluate[FileNameJoin[{Directory[], "Mathematica\\SomeFile.nb"}];

Also have a look at NotebookDirectory[]

• Seems like you've made a typo (wrong position of comma) , this one should be correct NotebookEvaluate[FileNameJoin[{Directory[] , "Mathematica\\SomeFile.nb"}]; Thanks for help! – icemtel Sep 4 '15 at 9:10
• @icemtel Indded. Typo fixed. – Ajasja Sep 4 '15 at 9:23
• I notice that you have not posted in almost a year. Have you decided to no longer participate in this community? I hope not. :-( – Mr.Wizard Aug 21 '16 at 8:48
• Hi @Mr.Wizard! Huh, is it that long already? I still read the occasional question:) But I've mostly switched to the Python ecosystem for my work-related stuff, so my lack of posts reflects my use of MMA. – Ajasja Aug 21 '16 at 9:09
• @Mr.Wizard On the contrary, I believe the MMA.SE is one of the nicest communities on the stackexchange network (and I still wear my t-shirt with pride to various geek meetings:) However my work is mostly numerical, for which MMA is perhaps not the best. I’m using the Ipython notebook, numpy and pandas as well as mdtraj and am very satisfied with the setup. – Ajasja Aug 22 '16 at 8:37

Always better to use FileNameJoin than to type in the full path name as a string. Further, you should give the name of each directory in the path individually. So you should use

NotebookEvaluate[
FileNameJoin[{Directory[], "Documents", "Mathematica", "SomeFile.nb"}]]


An alternative is not to specify the notebook file, but select it from a system open dialog. This can be done with

Module[{path},
path = SystemDialogInput["FileOpen", "*.nb", WindowTitle -> "Select a notebook"];
If[path === $Canceled,$Canceled, NotebookEvaluate[path]]]