Search code examples
xmlperlcmdziparchive

Export file list from ZIP archive without unzipping


I have hundreds of ZIP archives and each of them contains 2000 to 4000 xml files in it. Now I need some way to get a text file that will contain list of these xml files or at least file counts from each archive.

Is there any application to do this, or can I do this through cmd or perl?

I am not an expert programmer


Solution

  • 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