Link to home
Create AccountLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Extract all .zip files created with 7zip encrypted with password

C:\Users\User1\Files\ZippedFolders

I need to extract a huge amount of .zip folders created with 7zip which are password protected, and in many subfolders.

Using Powershell or another script, if the various subfolders which contain zip files are located in the path above, how can I get them to extract?
Avatar of Kimputer
Kimputer

Use the previous scripts you got already (for instance, the zip delete script), and modify it. Instead of deleting, use this:

7z e $_.FullName -oc:\output folder *.* -r

Open in new window

Make sure the 7z is the full folder and filename, usually

"c:\Program Files\7-Zip\7z.exe"

Open in new window

Avatar of E=mc2

ASKER

@Kimputer, thanks you. Can you write the script with this included?

Simple single line command can do it, from a command prompt do:

for /r "C:\Users\User1\Files\ZippedFolders" %A in ("*.zip") do "c:\program files\7-zip\7z.exe" x "%~A" -o"D:\Temp" *.* -r -pPASSWORD

Open in new window

Or from a BAT file adjust to:

for /r "C:\Users\User1\Files\ZippedFolders" %%A in ("*.zip") do "c:\program files\7-zip\7z.exe" x "%%~A" -o"D:\Temp" *.* -r -pPASSWORD

Open in new window

Make sure the path to the 7z.exe file is correct, and adjust the folders I used in my example to yours.


»bp
Avatar of E=mc2

ASKER

Thanks Bill.  I also want this script to automatically replace any files this is extracting, and overwrites the files...
Is this possible?
Avatar of E=mc2

ASKER

Additionally, I am not looking to extract files to a D:\Temp folder but in the same folder or path that the zip files are foudn that are being extracted. 
ASKER CERTIFIED SOLUTION
Avatar of E=mc2
E=mc2
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks Bill.  I also want this script to automatically replace any files this is extracting, and overwrites the files...
Is this possible?
Looks like you found the -xa option, good.
Additionally, I am not looking to extract files to a D:\Temp folder but in the same folder or path that the zip files are foudn that are being extracted.
Yes, I had indicated in my initial response "Make sure the path to the 7z.exe file is correct, and adjust the folders I used in my example to yours.", which meant you needed to adjust my example paths as needed.

So you took what I provided (which seems to be basically the core to your solution), adjusted the paths as I suggested, and added one additional option to the extract command that you desired, and no credit given for my contribution?  Interesting...

»bp