Unzip batch file script

ncalcaterra
ncalcaterra used Ask the Experts™
on
Hello... I'm looking for a batch file that will unzip all zip files within a folder to that same folder.  is there an easy script for doing this, that doesn't include winzip or any other third party?

Thanks for your help!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kent DyerIT Security Analyst Senior

Commented:
You can use the cabviewer from XP+

The key is centered around: CreateObject("MakeCab.MakeCab.1")

Here is the basis of the cab stuff..

http://www.robvanderwoude.com/vbstech_files_cab.php  Please Note: There is link to extract from this page as well which uses a VBS ..


HTH,

Kent
The only built-in features of XP that control Zip files are not available to batch files.  I would suggest getting 7-zip.  The 7z.exe is available at command line.

7-Zip: http://www.7-zip.org
REM Unzips all files in the current direcotry to the current directory
for %%f in (*.zip) do "C:\Program Files\7-Zip\7z.exe" x "%%f"

Open in new window

IT Manager
Commented:
This script is written in VBScript. Save it co unzip.vbs and run it by cscript /nologo unzip.vbs PathToZippFolder
On Error Resume Next
  Dim fso, folder, files, NewsFile,sFolder
 
  Set fso = CreateObject("Scripting.FileSystemObject")
  sFolder = Wscript.Arguments.Item(0)
  If sFolder = "" Then
      Wscript.Echo "No Folder parameter was passed"
      Wscript.Quit
  End If
  Set folder = fso.GetFolder(sFolder)
  Set files = folder.Files
 
  For each file In files
   If Right(File.Name,4) = ".zip" Then
    Wscript.Echo File.Name
    Unzip File.Name,sFolder
  End IF
  Next

Sub UnZIP (ZipFile,ExtractTo)

'If the extraction location does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
   fso.CreateFolder(ExtractTo)
End If
Wscript.Echo ExtractTo & "\" & ZipFile

set sa = CreateObject("Shell.Application")
set FilesInZip = sa.NameSpace(ExtractTo & "\" & ZipFile).items
sa.NameSpace(ExtractTo).CopyHere(FilesInZip)
Set fso = Nothing
Set sa = Nothing
End Sub
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Tomas ValentaIT Manager

Commented:
In my script you do not need to install any external ZIP programs. I am using buil-in ZIP functionality.
Some lines you can remove because I use it for debugging the script. The script is doing:
find all zip files in specified directory and to the same directory unzip them. That is all.

Author

Commented:
thanks for your help!  i'll try the vb script and if that becomes over my head, i'll look into the other suggestions provided here.  I'll report back with my outcome.
Tomas ValentaIT Manager

Commented:
Hello ncalcaterra,
did you try the script ?
Tominov
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.

Commented:
...and if the .zip file has a password?!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial