Skip to content

Instantly share code, notes, and snippets.

@jorgeramirez
Created January 15, 2012 17:08
Show Gist options
  • Save jorgeramirez/1616461 to your computer and use it in GitHub Desktop.
Save jorgeramirez/1616461 to your computer and use it in GitHub Desktop.
Simple script that unzips .zip files in cwd
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, re
"""
Unzip each .zip file inside the current working directory.
@author: Jorge Ramírez <jorgeramirez1990@gmail.com>
"""
pattern = re.compile("(.*)\.zip")
for f in os.listdir(os.getcwd()):
m = pattern.search(f)
if m:
sc = "mkdir {fn} && unzip -d {fn} {fn}.zip && rm {fn}.zip"
os.system(sc.format(fn=m.group(1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment