Reputation: 699
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?
Upvotes: 1
Views: 2355
Reputation: 32497
../../../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.
Upvotes: 4