1

I have following folder structure on Win7 machine:

C:\dev\bin\toplevel\python

I am running a script, say p1.py in this folder. I need to create folder termed Myscript under

C:\dev\matlab\scripts

I need to use path relative to my current folder \python. I tried using:

LibPathTst= '.\\dev\matlab\\scripts'
  os.makedirs(LibPathTst)

but this creates:

C:\dev\bin\toplevel\python\dev\matlab\scripts

Any help?

1 Answer 1

4
../../../matlab/scripts

Should be what you are looking for. Since you are using python, os.path.relpath (with the two paths as arts) gives you this result.

In a directory, there are two "special" nodes: "." and "..", pointing to the current directory and the parent directory, respectively.

1
  • 1
    You should also include that ../ refers to the parent directory
    – smac89
    Commented Aug 21, 2015 at 21:51

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.