Created
August 22, 2022 17:03
-
-
Save dustinbutterworth/9db2e3fa99337cdba1c838054ba5b8ba to your computer and use it in GitHub Desktop.
Untar, Gunzip all files in a directory into their own directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tarfile | |
base_dir = '/path/to/tarfiles' | |
import os | |
for path, directories, files in os.walk(base_dir): | |
for f in files: | |
if f.endswith(".tar.gz"): | |
filepath = f.replace(".tar.gz", "") | |
tar = tarfile.open(os.path.join(path,f), 'r:gz') | |
tar.extractall(path=filepath) | |
tar.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment