Skip to main content

Unzip Folders

#!/usr/bin/env python3

import sys
from pathlib import Path
from zipfile import ZipFile

source = Path(sys.argv[1])
if not source.is_dir():
raise RuntimeError(f'No folder "{source}" found.')

for zip in source.glob('*.zip'):
dest = zip.parent.joinpath(zip.stem)
i = 0
while dest.exists():
i = i + 1
dest = zip.parent.joinpath(f'{zip.stem} ({i})')
# Create a ZipFile Object and load in it
print('Extract to',
with ZipFile(zip, 'r') as zipObj: