1
$\begingroup$

How do I SetDirectory[] to the parent folder of the NotebookDirectory[].

Concrete example

enter image description here

pretend I am typing code into notebook1.nb, what do I type such that the output of Directory[] is path/to/parent_dir/

+1 for elegant and easy to remember answer

$\endgroup$
3
  • $\begingroup$ SetDirectory[FileNameDrop[NotebookDirectory[], -1] ] $\endgroup$
    – conor
    Aug 14, 2021 at 20:19
  • 4
    $\begingroup$ SetDirectory[ParentDirectory[NotebookDirectory[]]]. $\endgroup$
    – Domen
    Aug 14, 2021 at 20:25
  • $\begingroup$ SetDirectory[NotebookDirectory[]]; SetDirectory[ParentDirectory[]]; $\endgroup$
    – conor
    Aug 14, 2021 at 20:27

1 Answer 1

4
$\begingroup$

You can use either

SetDirectory[ParentDirectory[NotebookDirectory[]]];

or

SetDirectory[FileNameDrop[NotebookDirectory[]]];
$\endgroup$

Your Answer

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

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