I need help figuring out how to extract the contents of several zip folders within a directory. I am having issues with the following script:
get-childitem *zip | expand-archive | foreach {-destinationpath C:\\...genericpathdestination }
The command works, as it successfully creates unzipped versions in the destination path, but the issue is that it creates each new zip folder within each subsequent folder. To clarify, when I run the command to unzip:
Folder 1 Folder 2 Folder 3
The command saves Folder 3 within Folder 2 and its contents, then Folder 2 (which includes Folder 3) within Folder 1.
I have about 40+ folders that I need to work with so you can see how this solutions becomes counter intuitive rather fast.
All relevant input/help is greatly appreciated.
Sincerely, RM
The foreach
isn't needed in this case. The -force
is to update the destination folder.
Get-ChildItem -Path "C:\Users\Administrator\Documents\*.zip" | Expand-Archive -DestinationPath "C:\Users\Administrator\Documents\Here is the unzipped stuff" -Force