How to List the Files in a Zip Archive Without Decompressing It

How can I list the files in a zip archive without decompressing it?

Perreal's answer is right, but I recommend installing atool (look for it in your distribution's package manager). Then, for any kind of archive file, bzip2, gzip, tar... you have just one command to remember :

als archive_name

Is there a way to open files in a zip file without decompressing (c#)

i believe you can use the System.IO.Compression library...

Assembly: System.IO.Compression.ZipFile.dll

something like the following...

using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
{
entry.ExtractToFile(destinationPath);
}
}
}

Export file list from ZIP archive without unzipping

Something like this:

#!/usr/bin/perl
use strict;
use warnings;

use Archive::Zip;

my $archive_name = "archive.zip";

my $archive_extract = Archive::Zip -> new ( $archive_name );
foreach my $member ( $archive_extract -> members() )
{
print $member -> fileName(),"\n";
}

You will, of course, need to supply your own directory search. I would recommend looking at File::Find for that

How to read data from a zip file without having to unzip the entire file

DotNetZip is your friend here.

As easy as:

using (ZipFile zip = ZipFile.Read(ExistingZipFile))
{
ZipEntry e = zip["MyReport.doc"];
e.Extract(OutputStream);
}

(you can also extract to a file or other destinations).

Reading the zip file's table of contents is as easy as:

using (ZipFile zip = ZipFile.Read(ExistingZipFile))
{
foreach (ZipEntry e in zip)
{
if (header)
{
System.Console.WriteLine("Zipfile: {0}", zip.Name);
if ((zip.Comment != null) && (zip.Comment != ""))
System.Console.WriteLine("Comment: {0}", zip.Comment);
System.Console.WriteLine("\n{1,-22} {2,8} {3,5} {4,8} {5,3} {0}",
"Filename", "Modified", "Size", "Ratio", "Packed", "pw?");
System.Console.WriteLine(new System.String('-', 72));
header = false;
}
System.Console.WriteLine("{1,-22} {2,8} {3,5:F0}% {4,8} {5,3} {0}",
e.FileName,
e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
e.UncompressedSize,
e.CompressionRatio,
e.CompressedSize,
(e.UsesEncryption) ? "Y" : "N");

}
}

Edited To Note: DotNetZip used to live at Codeplex. Codeplex has been shut down. The old archive is still available at Codeplex. It looks like the code has migrated to Github:

  • https://github.com/DinoChiesa/DotNetZip. Looks to be the original author's repo.
  • https://github.com/haf/DotNetZip.Semverd. This looks to be the currently maintained version. It's also packaged up an available via Nuget at https://www.nuget.org/packages/DotNetZip/

Access to zipped files without unzipping them

You can pipe an individual member of a zip file to stdout with the -p option

In your code change

tarArchiveFiles=`tar -tzf $file`

to

tarArchiveFiles=`unzip -p zipfile $file | tar -tzf -`

replace "zipfile" with the name of the zip archive where you sourced $archiveFiles from

Listing the contents of zip files within a tar file

Starting with tar, you can get it to write to stdout with the -O command line option.

Next to the unzip part of the problem. The standard Linux infozip versions of zip/unzip don't support reading input from stdin. The funzip command, which is part of infozip can read from stdin, reads from stdin but it only supports uncompression. It doesn't have an option to list the contents.

Luckily Java jar files are really just zip files with a well-defined structure and the jar command can read from stdin and list the contents of the input file

So, assuming you have a tar file called my.tar that only contains zip files, something like this should list the names of the files in the embedded zip files

tar xOf my.tar | jar -t


Related Topics



Leave a reply



Submit