How can I use something like that


Instead of


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[]

  • $\begingroup$ 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! $\endgroup$ – icemtel Sep 4 '15 at 9:10
  • $\begingroup$ @icemtel Indded. Typo fixed. $\endgroup$ – Ajasja Sep 4 '15 at 9:23
  • $\begingroup$ I notice that you have not posted in almost a year. Have you decided to no longer participate in this community? I hope not. :-( $\endgroup$ – Mr.Wizard Aug 21 '16 at 8:48
  • $\begingroup$ 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. $\endgroup$ – Ajasja Aug 21 '16 at 9:09
  • 2
    $\begingroup$ @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. $\endgroup$ – 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

  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

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

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.