0

is there a way to get the path of a file inside a zip file? I would like to do something like this:

archive = zipfile.ZipFile('pathToZip/file.zip','r')
files = archive.infolist()
for file in files:
        name = file.filename
        p1 = subprocess.Popen(["exiftool", "pathToZip/file.zip/"+name], stdout=subprocess.PIPE)
        output = p1.communicate()[0]
        print output

So the problem is that exiftool command needs a path, but I don't want to extract the zip file! Is there a way to solve this?

Labo29
  • 117
  • 3
  • 13
  • no, it is a zip file not a folder. I'm afraid it is very difficult to get a program to use the content of a zip file without unzipping it. – Tadhg McDonald-Jensen May 03 '16 at 12:56
  • exiftool definitely needs a proper file to work with, sorry. – Tadhg McDonald-Jensen May 03 '16 at 13:02
  • @TadhgMcDonald-Jensen: I believe zip folders are builtin in explorer on Windows and it is likely that you can mount a zip file using something like fuse on Linux. Though OP could try to extract the necessary file on-the-fly using Python and stream its content as exiftool's stdin (`stdin=PIPE` + `shutil.copyfileobj(extracted_file, p.stdin)`). If `exiftool` requires a filename then something like [`/dev/fd/%d' % pipe_fileno` could be used](http://stackoverflow.com/q/28840575/4279) – jfs May 03 '16 at 21:13
  • @J.F.Sebastian thank you! I used archivemount (based on fuse) and it works! – Labo29 May 05 '16 at 08:31

0 Answers0