I have a tar archive in which I have a directory that I need to extract in this directory. For example: I have a directory
TarPrefix / x / y / g
in the tar archive I want to extract it to this target directory, for example: extract / a / this directory should contain all the files and directories contained in the TarPrefix / x / y / z directory.
subdir_and_files = [ tarinfo for tarinfo in tar.getmembers() if tarinfo.name.startswith("subfolder/") ]
to get a list of all the members in the path of the "Subfolder /" directory, and then I extract it with tar.extractall(extracted/a,subdir_and_files) but it extracts all the members with their directory path. For example, this results in the extraction of / a / x / y / z. Could you help me in extracting these files in this folder.
gaurav
source share