split
#1
what is easiest way change path one root upper.

i need convert path=dir1\dir2\dir3\ to path=dir1\dir2\

maybe rsplit, but is it supported in xbmc?

problem is :
from there must choose:
version 1= path=dir1\dir2\dir3\version1\this
version 2= path=dir1\dir2\dir3\version2\this
version 3= path=dir1\dir2\dir3\version3\this


must put in there:
dir1\dir2\dir3\this

thanks if anybody can help
Reply
#2
want to do this with python?

path.split('\\') gives an array: ['dir1', 'dir2', 'dir3', '']

from there you will be able to join it once again.
Reply
#3
thanks a lot

i must try again Smile
Reply
#4
for crossplatform issues I would suggest using os.path.sep ..

path = os.path.join('dir1','dir2','dir3')
dirs = path.split(os.path.sep)

where dirs is an array ['dir1', 'dir2', 'dir3']
Reply
#5
os.sep
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#6
You can also use:
Code:
mydir = os.path.dirname( path )
It will give you te directory or the item identified by the path (if it ia a file or a dir).
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply

Logout Mark Read Team Forum Stats Members Help
split0