I want to unzip all files in a certain directory and preserve the folder names when unzipped.
The following batch script doesn't quite do the trick. It just throws a bunch of the files without putting them into a folder and doesn't even finish.
What's wrong here?
for /F %%I IN ('dir /b /s *.zip') DO (
"C:\Program Files (x86)\7-Zip\7z.exe" x -y -o"%%~dpI" "%%I"
)
To unzip files Open File Explorer and find the zipped folder. To unzip the entire folder, right-click to select Extract All, and then follow the instructions. To unzip a single file or folder, double-click the zipped folder to open it. Then, drag or copy the item from the zipped folder to a new location.
Use the Windows Command Prompt to Make ZIP FilesUse the cd command to go to the folder where your files are located. Enter the following command in the Command Prompt window and hit Enter. Replace output. zip with the name you want to give your ZIP file, and myfile.
Ansgar's response above was pretty much perfect for me but I also wanted to delete archives afterwards if extraction was successful. I found this and incorporated it into the above to give:
for /R "Destination_Folder" %%I in ("*.zip") do (
"%ProgramFiles%\7-Zip\7z.exe" x -y -aos -o"%%~dpI" "%%~fI"
"if errorlevel 1 goto :error"
del "%%~fI"
":error"
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With