0

I know that Windows Explorer, 7-Zip, Beyond Compare, and others can look into a zipped directory to see the file structure and file names.

Is there any way to compare those file names to the unzipped directory? Ideally, comparing the file names within multiple Zip files to one big unzipped directory?

Essentially, I want to check that the folders unzipped properly before I go ahead and delete all of them.

2
  • I think you would not gain anything. You would need to unzip to a temp folder to compare to the previously unzipped files.
    – anon
    Commented Mar 19 at 22:43
  • 1
    You could programmatically look into a zip file and do this comparison. What have you tried regarding this? 7zip has a command line version included in the product that may be helpful in doing this. Commented Mar 19 at 23:18

3 Answers 3

0

Beyond Compare can do this, as long as the filenames inside the zips are unique.

  1. Open Beyond Compare's Folder Compare.
  2. Load a folder containing all the zip files on the left.
  3. Load a folder containing the extracted folders on the right.
  4. Click the Rules toolbar button (referee icon).
  5. Go to the Handling tab.
  6. Set Archive handling (e.g. zip files) to As folders always.
  7. Click OK.
  8. Select View > Ignore Folder Structure from the menu.

This will expand all the zip files, then align contents based on filename while ignoring subfolder or zip file name. It doesn't handle duplicate filenames.

1
  • Wow I just saw this, thank you! Unfortunately, I just deleted the zips, so I can't test it out (although I have another big download coming up, so maybe I might).
    – Medajor
    Commented Mar 20 at 18:32
0

Another solution to this problem is to use 7-zip's CLI.

  1. First, follow this to make sure the CLI works properly
  2. Then navigate to the directory containing all you zip files and use the following command: 7z l *.zip | Out-File -FilePath ./zipped_files.txt The first part of this command has 7-zip perform the list operation on every zip archive in the directory. The part after the vertical bar has PowerShell/cmd output the response to a file.
  3. This file will have a list of every file that is in the zip directories. One of the last lines of the file also contains the total size and number of files between all of the included archives. This is where I stopped since the number of files matched the number in my unzipped directory.

If you want to proceed:

  1. Parse all the file paths using regex.
  2. Use another tool to get a list of all file paths in the unzipped directory. (tree?)
  3. Run a file diff check to find orphaned files.
0

This can be done in PowerShell using the shell.application com object.

Assuming:

C:\Test
│   Zipped1.zip (conains new1.txt, new2.txt, new3.txt)
│   Zipped2.zip (conains new4.txt, new5.txt, new6.txt)
│
└───UnZipped
        New1.txt
        New2.txt
        New3.txt
        New4.txt
        new5.txt
        new6.txt
$UnzippedFilePath   = 'C:\tEST\UnZipped'
$ZippedFilePaths    = @'
C:\tEST\Zipped1.zip
C:\tEST\Zipped2.zip
'@ -split "`n"

###    Note: If Explorer optioins are set to hide known extensions,
###   "$_.Name" will have no extension.
###   Splitting "$_.Path" ensures the extension is inclueded

$ZippedFileNames   = $ZippedFilePaths.ForEach{@($shell.NameSpace($_).Items()).ForEach{$_.Path.Split('\')[-1]}}
$UnzippedFileNames = (Get-ChildItem $UnzippedFilePath).Name

###   This returns names that don't match
Compare-Object $ZippedFileNames $UnzippedFileNames

### This returens names that are matched
Compare-Object $ZippedFileNames $UnzippedFileNames -IncludeEqual

Output (from -IncludeEqual)


InputObject SideIndicator
----------- -------------
New1.txt    ==
New2.txt    ==
New3.txt    ==
New4.txt    ==
new5.txt    ==
new6.txt    ==

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .