AnsweredAssumed Answered

Unzip zip files in folders and subfolders with python

Question asked by yaron148 on Feb 5, 2015
Latest reply on Feb 7, 2015 by yaron148

Hello everyone,

I try to unzip 150  zip files which contain shapefiles. All the zip files as different names, and they all spread in one big folder that divided to a lot of sub folders and sub sub folders.i want to extract each archive to separate folder with the same name as the original zip file name and also in the same place as the original zip file . I'm working with arcview 10.3 and my code is:

 

import zipfile  
import arcpy,os,os.path,sys
from arcpy import env

pattern = '*.zip'
folder = r"C:\Project\layers" 
files_process = []
for root,dirs,files in os.walk(r"C:\Project\layers"):
    for filenames in files:
        if filenames == pattern:
            files_process.append(os.path.join(root, filenames))
            zip.extract()

 

After i run the code nothing happened.

Thanks in advance for any help on this.

Outcomes