0

I was looking for a solution to unzip my .zip file with a windows bat file. However the solution i found:

@echo off
setlocal
cd /d %~dp0
Call :UnZipFile "C:\Temp\" "c:\path\to\batch.zip"
exit /b

:UnZipFile <ExtractTo> <newzipfile>
set vbs="%temp%\_.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs%  echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If NOT fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%

Only extracts the first files which are in the myzip.zip/ path. For example myzip.zip/file1.txt will get extracted while myzip.zip/folder1/file2.txt will not. How can i modify this script so all files and folders within the zip will get extracted?

  • 2
    take a look at this : http://stackoverflow.com/questions/28043589/how-can-i-compress-zip-and-uncompress-unzip-files-and-folders-with-batch – npocmaka Oct 12 '15 at 01:29
  • 1
    Possible duplicate of [How to write a batch file that can unzip a file into a new folder with the same name?](http://stackoverflow.com/questions/31438921/how-to-write-a-batch-file-that-can-unzip-a-file-into-a-new-folder-with-the-same) One of the great solutions provided by [npocmaka](http://stackoverflow.com/users/388389/npocmaka) was used in the answer of this question. – Mofi Oct 12 '15 at 05:46
  • This is not exactly your situation, but it might be helpful. http://stackoverflow.com/questions/24507585/how-to-extract-without-creating-recursive-folders – lit Oct 12 '15 at 13:30

0 Answers0