Expand-Archive odd errors
Asked Answered
P

1

9

I am trying to get at some data in an Autodesk Revit file, which is just a ZIP under the skin. I can use 7zip to extract but I am hoping to automate things with all native PS or Windows. I tried Expand-Archive after I renamed the RVT file to ZIP, but Expand-Archive has an odd error. The code is

Expand-Archive -path:'C:\RevitVersionTest\22-PLUMB-CLR-RECTANGULAR.zip' -destinationPath:'C:\Revit Fam'

And the error is

New-Object : Exception calling ".ctor" with "3" argument(s): "End of Central Directory record could not be found."

Pren answered 21/6, 2018 at 22:14 Comment(3)
It thinks the zip file is malformed. Can you open it with other zip utilities? Can WIndows Explorer open it?Slumberland
@zdan, I can use 7zip, either manually or using it's command line option from within PS. But Explorer claims the file is invalid even after a rename.Pren
Maybe the input file format isn't quite zip compliant enough. Try getting 7-zip to rezip it to see if that's the case.Slumberland
Y
6

The file is corrupt. Re-download (or obtain) the ZIP file.

Background: I landed here having experienced the same error downloading a ZIP from Google Drive through a private link:

Invoke-WebRequest -Uri $zipFile -OutFile "$destPath\myZip.zip"

...then using the command:

Expand-Archive c:\a.zip -DestinationPath c:\a` 

The file downloaded but it wouldn't extract. I downloaded through the browser using the UI, and then compared the download file sizes. Sure enough, the downloaded ZIP was corrupted. When I updated the URL to a Google Docs link directly to the file (that's public with permission), the ZIP then downloaded and extracted correctly.

Hence, comments under the question alluding to the file being corrupt are correct.

Yclept answered 7/5, 2019 at 20:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.