dotfiles/scripts/unziptree

23 lines
507 B
Plaintext
Raw Normal View History

2018-10-06 10:27:36 +02:00
#!/usr/bin/env python
import os
import subprocess
for root, dirs, files in os.walk("."):
for name in files:
base, ext = os.path.splitext(name)
if ext.lower() != ".zip":
continue
filepath = os.path.join(root, name)
dirpath = os.path.join(root, base)
print(filepath)
os.mkdir(dirpath)
cmd = ["unzip", os.path.realpath(filepath)]
r = subprocess.run(cmd, cwd=dirpath)
r.check_returncode()
os.unlink(filepath)