Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9089077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:03:34+00:00 2026-06-16T22:03:34+00:00

I am new to powershell and looking to list all the files, contained in

  • 0

I am new to powershell and looking to list all the files, contained in zip files in a directory. I don’t want to use any third-party tool.

Structure of the directory is
mydir > dir
a.zip
b.zip
c.zip

with each file containing files named 1.txt or 2.txt or 3.txt

I am trying to get an output in the form

a.zip:1.txt
a.zip:2.txt
b.zip:files\3.txt
b.zip:4.txt
c.zip:1.txt
d.zip:10.txt 

and so on.

Unfortunately my environment is not 4.5 but 4.0.
I was able to write up this code but it still needs a lot of parsing for clean up as unzip gives a lot of extra information.

$packagedir="C:\Packages"
$unzipcmd = "c:\bins\unzip.exe -l"
$unmatchstr = "*Archive*"
pushd .
cd $packagedir

$filelist= Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName

 foreach ($item in $filelist) 
 {$ziplist = Invoke-Expression "$unzipcmd $item"; 
 foreach ($item2 in $ziplist) 
  {
   if ($item2.Contains("Archive") )
   {

   }
   else
   {
     echo $item "::" $item2}} 
   }
popd

Is there any easier way to parse this. There is a lot of extra information in the unzip -l output, like Column headers, separators and dates and other date before every file name.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:03:36+00:00Added an answer on June 16, 2026 at 10:03 pm

    In .NET Framework 4.5 there is a ZipFile class that is quite handy.
    To list the entries in an archive file, you can use it like this in Powershell:

    [Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
    [IO.Compression.ZipFile]::OpenRead($sourceFile).Entries
    

    Update: This seems to do the trick :]

    [Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
    
    foreach($sourceFile in (Get-ChildItem -filter '*.zip'))
    {
        [IO.Compression.ZipFile]::OpenRead($sourceFile.FullName).Entries.FullName |
            %{ "$sourcefile`:$_" }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to copy files from a directory structure over to a new
I'm new to PowerShell and I'm looking for a way to un-install multiple applications.
I'm looking to use PowerShell to alter XML. I haven't been able to copy
I'm relatively new to PowerShell, and I was trying to copy files using a
I'm pretty new to powershell, so I won't be surprised at all if I'm
I'm new to PowerShell, but I would like to use it, because there isn't
I am new to powershell and have figured out how to use it to
I'm looking for a DOS command to list all sites and virtual directories in
First of all, I'm quite new to Powershell and scripting in general your patience
When I use Enter-PSSession with Powershell I get a new prompt like [HOSTNAME]:> This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.