For creating tar.gz file I use the below code.
import os
import tarfile
def tardir(path, tar_name):
with tarfile.open(tar_name, "w:gz") as tar_handle:
for root, dirs, files in os.walk(path):
for file in files:
tar_handle.add(os.path.join(root, file))
tardir('C:/../../projects/project_folder', 'C:/../../projects/project_folder/tar_files/tar_file.tar.gz')
tar.close()
I want gzip the tar_files folder and when i unzip it I only want to see this folder. But with the above code, inside of tar file I see it stores with directory tree. Like when I open it i see the below folders
/../../projects/project_folder
How can i solve this problem ? Thanks for answering