AnsweredAssumed Answered

Extract Zip files to one folder

Question asked by yaron148 on Jun 2, 2015
Latest reply on Jun 4, 2015 by Dan_Patterson

Hi everyone,

Continuously to Unzip files from directory tree ,when i try to  extract zip files that contain files with same names in it to one folder , some files got lost because duplication names. I use this code (i work with python 2.7.8 and arcmap 10.3):

 

import zipfile,fnmatch,os

# EXTRACT ALL ZIP FILES IN DIRECTORY TREE TO ONE SPECIFIC FOLDER 

rootPath = r"C:\Project"
pattern = '*.zip'
for root, dirs, files in os.walk(rootPath):
    for filename in fnmatch.filter(files, pattern):
        print(os.path.join(root, filename))
        outpath = r"C:\Project\gis\layers\taba\new"  
        print root
        print filename
        zipfile.ZipFile(os.path.join(root, filename)).extractall(r"C:\Project\gis\layers\taba\new")

 

I don't know how to overcome that issue

Thank for any help

Outcomes