2016-12-25

Python - Find all zip files in nested folders, recursively, and unzip to a single given folder

import or, fnmatch, zipfile

ssourceFolder = "/entire_absolute_path_here/"targetUnzippedFolder = "/entire_absolute_path_here/"

for root, dirs, files in os.walk( sourceFolder ):
   for filename in fnmatch.filter( files, "*.zip" ):
      print "   " + os.path.join(root, filename)
      zipfile.ZipFile( os.path.join(root, filename) ).extractall( targetUnzippedFolder )

No comments:

Post a Comment