Equivalent functionality of tar --strip in python tarfile

Viewed 760

I have a tar file with the following directory structure: a/b/c/xyz.txt

I want to extract the files from this tar file by ignoring the parent directory 'a'. After extraction, I am expecting the following directory structure: b/c/xyz.txt

With tar command, we can use --strip=1 option. How to do this using tarfile in python? tarfile.getmembers() allows us to get a subset from the top by including all the parent directories. How to remove the parent directory and get the remaining subset?

Thanks.

0 Answers
Related