Hi Itay, current FME seems not to have the capability to unzip recursively.
Â
This example is from my old PythonCaller implementation. FYI.
Â
-----
Â
import fmeobjects
Â
import os, re, zipfile
Â
Â
class RecursiveUnzipper(object):
Â
  def input(self, feature):
Â
    def clearDirectory(path):
Â
      if os.path.isdir(path):
Â
        for t in Â'%s/%s' % (path, s) for s in os.listdir(path)]:
Â
          clearDirectory(t)
Â
        os.rmdir(path)
Â
      else:
Â
        os.remove(path)
Â
        Â
Â
    # Get zip file path and destinction directory path.
Â
    zipPath = feature.getAttribute('_zip')
Â
    outDir = feature.getAttribute('_out_dir')
Â
    if os.path.exists(zipPath):
Â
      # If specifid output directory exists, remove it beforehand.
Â
      if os.path.exists(outDir):
Â
        clearDirectory(outDir)
Â
      self.index = 0
Â
      self.unzip(feature, zipPath, outDir)
Â
    self.pyoutput(feature)
Â
    Â
Â
  # Unzip recursively
Â
  # Extracted file paths will be stored in a list called "_unzipped{}".
Â
  def unzip(self, feature, path, outDir = None):
Â
    if os.path.isfile(path):
Â
      m = re.match(r'^(.+)\\.zip$', path, re.IGNORECASE)
Â
      if m != None:
Â
        zip = zipfile.ZipFile(path)
Â
        if zip.testzip() == None:
Â
          dir = outDir if outDir else m.group(1)
Â
          zip.extractall(dir)
Â
          for t in Â'%s/%s' % (dir, s) for s in os.listdir(dir)]:
Â
            self.unzip(feature, t)
Â
      else:
Â
        feature.setAttribute('_unzipped{%d}' % self.index, path)
Â
        self.index += 1
Â
    elif os.path.isdir(path):
Â
      for t in i'%s/%s' % (path, s) for s in os.listdir(path)]:
Â
        self.unzip(feature, t)
Â
-----
Â
Â
Takashi
Hi Takashi,
Â
Â
Fantastic! thanks for your help.
Â
Itay