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?

llrs
3,40341 silver badges73 bronze badges
asked Aug 21, 2015 at 21:39

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.

answered Aug 21, 2015 at 21:48
Sign up to request clarification or add additional context in comments.

1 Comment

You should also include that ../ refers to the parent directory

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.