0

I have tar.gz with the following structure:

tarFile.tar.gz
├── folder1
│   ├── folder2
│       |-- folder3
             |-- folder
                  |--img1.jpg
                  |--img2.jpg
                  |--img3.jpg

I need to store the imgs in different directories. How can I parse through the tar file and place these images into different directories without extracting the tar file first ?

thatGuy
  • 57
  • 6
  • You should leverage tarfile [module](https://docs.python.org/3/library/tarfile.html). You can use get members function and extract images into another folder using extractfile or extract function https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.getmembers https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extract Additionally see for more help [here](https://stackoverflow.com/questions/2018512/reading-tar-file-contents-without-untarring-it-in-python-script) – teedak8s Oct 31 '22 at 00:35

0 Answers0