Coding Global Background
Coding Global

Get relative path from absolute path

Archived 3 years ago
2 messages
1 members
Created 3 years ago
Updated 3 years ago
Open in Discord
Q
QWERTZ

Playing Custom Status

Verified
So I made an application which compresses files (NOT ZIP). But this isnt the problem right now. Now I am at the point: decoding and encoding works fine but if I wanted to encode a folder, lets say my folder structure is like this:
ALL FILES:
C:\users\qwertz\test\main.py # the python file
C:\users\qwertz\test\directory\ # the directory which gets compressed
C:\users\qwertz\test\direcotry\subfolder\ # some subfolders
C:\users\qwertz\test\direcotry\subfolder\hello.txt # some subfiles

We don't know how much subfolders / files are in there. If I did dir /s /b /o:gn and saved the output to a file, then I would get smth like this:
C:\users\qwertz\test\directory\subfolder\hello.txt

It correctly gives me all files. But those paths are absolute (for example C:\users\qwertz\test\directory\subfolder\hello.txt should be relative to directory: \subfolder\hello.txt.
How can I achieve this? Thanks for help!

Replies (2)