How can I get the most left part of relative path in python?
I started with something like this:
/var/tmp/workdir/1/foo/bar/test.jpg
Then I removed some of it to get:
1/foo/bar/test.jpg
Using:
rel_path = os.path.relpath(path,base_dir)
Now how can I get the most left part - the "1" ?
I can only find tools that go from the right side, but in this case I want the most left thing because it correspondents with a user ID. Also I want to avoid going from the right side, because there might be more sub directories.