0

I realize this question is stretching the capabilities of batch scripting, but is there a way to view the files and directories of a .zip file without unzipping the file? For example, say there is a .zip file named myfile.zip and has a subdirectory called status which contains a status.xml file. Is there a way to view the contents of the status.xml file through the batch scripting language?

Thanks in advance

Don Roby
  • 40,677
  • 6
  • 91
  • 113
Jeff K
  • 243
  • 3
  • 10

3 Answers3

1

Various zip command line utilities will allow you to list the contents of the zip archive, but you said you also wanted to view the contents. You can view the contents by extracting the file from the archive. 7zip will do it as mentioned above. Info-Zip also has a couple of command line utilities that do the same (you can find the binaries here).

If you want to view the contents of status.xml without having to write the file to disk, you can pipe it out using the unzip.exe command line utility from Info-Zip.

unzip -p myfile.zip status.xml | more
unzip -p myfile.zip status.xml > status.xml

To use the same utility to list the zip file's contents:

unzip -l myfile.zip
Nathan Moinvaziri
  • 5,506
  • 4
  • 29
  • 30
  • Thanks for the reference! Although I was looking for more of a standalone approach, the unzip command worked great! – Jeff K Oct 15 '12 at 16:54
0

Here's a way to do it without external tools with zipjs.bat introduced here:

call zipjs list -source C:\\myZip.zip -flat no
call zipjs list -source C:\\myZip.zip\\inZipDir -flat yes
Community
  • 1
  • 1
npocmaka
  • 55,367
  • 18
  • 148
  • 187
0

You can use zip.js to get data from the myzip.file, here is a part of the code:

zipFs.importHttpContent("1.zip", false, function() {
    var firstEntry = zipFs.root.children[0];
    console.log(zipFs)
    firstEntry.getData64URI("image/png",function(data) {
        console.log(data)
    });
}, onerror);

======================

the origin code is from http://gildas-lormeau.github.com/zip.js/

Draken
  • 3,134
  • 13
  • 34
  • 54
feixiangsnail
  • 45
  • 1
  • 1
  • 6