Unzip a file using batch scripting


I have a file Nirmal.zip in a E drive Suppose I extract the basename of the file alone "Nirmal" and created a folder out of it. Now there exists a folder named Nirmal and zip file named Nirmal.zip I need to extract the contents of Nirmal.zip and put it into newly created Nirmal Folder.

How to do the above using batch scripting


Windows doesn't include unzip.exe or any other similar sort of console executable for unzipping files. You can script it using Shell.Application with <a href="https://gist.github.com/889769" rel="nofollow">JScript</a> or <a href="http://www.robvanderwoude.com/vbstech_files_zip.php" rel="nofollow">VBscript</a>, or even <a href="http://www.howtogeek.com/tips/how-to-extract-zip-files-using-powershell/" rel="nofollow">PowerShell</a> if you wish.

In the spirit of thoroughness, here's a Windows batch / JScript hybrid script that does what you ask:

@if (@a==@b) @end /* :: unzip.bat :: usage: unzip.bat zipfile.zip :: extracts zipfile.zip to .\zipfile\ :: begin batch portion @echo off setlocal if "%~1"=="" ( echo Usage: %~nx0 filename.zip goto :EOF ) cscript /nologo /e:jscript "%~f0" "%~f1" echo( echo Unzipping complete. goto :EOF :: end batch portion :: begin JScript portion */ // https://gist.github.com/889769 // slightly modified by rojo for http://stackoverflow.com/a/27049936/1683264 function unzip(zipfile, unzipdir) { var fso = new ActiveXObject('Scripting.FileSystemObject'), shell = new ActiveXObject('Shell.Application'), dst, zip; if (!unzipdir) unzipdir = '.'; if (!fso.FolderExists(unzipdir)) fso.CreateFolder(unzipdir); dst = shell.NameSpace(fso.getFolder(unzipdir).Path); zip = shell.NameSpace(fso.getFile(zipfile).Path); for (var i=0; i<zip.Items().Count; i++) { try { if (fso.FileExists(zipfile)) { WSH.Stdout.Write('Unzipping ' + zip.Items().Item(i) + '... '); dst.CopyHere(zip.Items().Item(i), 4 + 16); WSH.Echo('Done.'); } } catch(e) { WSH.Echo('Failed: ' + e); } } } var zipfile = WSH.Arguments(0), dest = zipfile.replace(/\.\w+$/, '\\'); unzip(zipfile, dest);


  • Boost Spirit char parser
  • boost spirit 2 : is there a way to know what is the parser progression percentage?
  • Invert y-axis in barplot
  • How to split a sentence with an escaped whitespace?
  • jQuery UI datetimepicker and ASP.NET CompareValidator for DataTypeCheck
  • How to write a boost::spirit::qi parser to parse an integer range from 0 to std::numeric_limits::max
  • Use WMI to find dependencies of a service and then differentiate dependent Services from dependent D
  • How do I completely disable JavaScript errors using VS 2008 and IE
  • how to make folder name with yesterday's date?
  • Unsupported Operation. A document processed by the JRC engine cannot be opened in the C stack.
  • Excel VBA: search a string to find the first non-text character
  • vbscript syntax in asp classic
  • CRLF in VBScript
  • Powershell - Change windows 7 background to image off a website
  • VLCJ - playing a video from the “res” folder works great in eclipse, but not from the executable JAR
  • How to preserve alias property while signing app?
  • Find duplicate values in one of the two columns in a text file
  • Azure Resource Template Deployment issues
  • powershell: script to start a program with parameters?
  • Access VBScript variable within Javascript inside of an HTA
  • In powershell, using the export-csv cmdlet, my ints are being encapsulated by quotes any idea why?
  • How to package a jar and all dependencies within a new jar with maven
  • Unable to run SDL program in Eclipse but able to do so in Windows Explorer
  • How to send control C to Mac Terminal using python?
  • user data scripts fails without giving reason
  • in batch how do i use taskkill properly
  • why calling cd shell command through system() or execvp() from a child process won't work?
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • How can I get the full list of running processes on a Mac from a python app
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Spark fat jar to run multiple versions on YARN
  • Spring Data JPA custom method causing PropertyReferenceException
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Upload files with Ajax and Jquery
  • How to pass list parameters for each object using Spring MVC?
  • How to include full .NET prerequisite for Wix Burn installer
  • Proper way to use connect-multiparty with express.js?
  • Is it possible to post an object from jquery to bottle.py?