I tried the following:


The documentation for SetDirectory says:

For a relative path name, SetDirectory sets the directory relative to the current working directory.

So it seems that SetDirectory interprets my argument as a relative path name. How can I get SetDirectory to interpret my argument as an absolute path name, so that the result is /Library/Mathematica instead of /Users/John/Library/Mathematica?


2 Answers 2


Not really a Mathematica specific question but in Mac OS X absolute paths begin with a / character exactly as you give in your desired result, so


If you want Mathematica to interpret it as an absolute path, why don't you pass it one? In Windows:


will set the path to D:\Library\Mathematica.

  • $\begingroup$ are the double backslashes really necessary, in Windows? $\endgroup$
    – magma
    Jul 14, 2014 at 9:22
  • $\begingroup$ @magma - Apparently not, but I saw them in a notebook I got from WRI, and I sticked to it. $\endgroup$
    – stevenvh
    Jul 14, 2014 at 9:25
  • $\begingroup$ @magma - Yes, otherwise you'd get the "Unknown string escape" error. When you copy paste a file path within a Mathematica string (""), MMA will prompt you to allow it to insert escape--whatever that means--and you should pick "Yes". $\endgroup$
    – seismatica
    Jul 14, 2014 at 9:57
  • $\begingroup$ @seism - I tried it with a single backslash, and it also works. No error, no warning, no prompt. $\endgroup$
    – stevenvh
    Jul 14, 2014 at 10:00
  • 1
    $\begingroup$ @stevenvh I have no idea why mine showed the error. I took a screenshot of it: !Mathematica graphics. Could you help me use single backlash without error? $\endgroup$
    – seismatica
    Jul 14, 2014 at 10:20

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.