Unzip file from source to destination within user directory across multiple versions of windows
DelUnzip.cmd:
RD /S /Q "%USERPROFILE%\My Documents\Unzipped"
cscript UnzipZip.vbs
UnzipZip.vbs:
strZipFile = "\file.zip"
strUnzipped = "\Unzipped\"
Sub UnZip(ExtractTo,ZipFile)
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
fso.CreateFolder(ExtractTo)
End If
Set objShell = CreateObject("Shell.Application")
Set FilesInZip=objShell.NameSpace(ZipFile).items
ObjShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
Set fso = Nothing
Set objShell = Nothing
End Sub
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("MyDocuments")
strZipPath = strDesktop & strZipFile
strUnzipPath = strDesktop & strUnzipped
UnZip strUnzipPath , strZipPath
Here I've tried to summarize ways of how can files and folder be zipped without external tools:
And also tried to create a tool for common usage capable of zipping unzipping and few more features.
ZIPJS.BAT - it does not need additional files like .vbs
nor creates a temp ones.All in one and called like a normal bat file.
to unzip folder of file you can use this:
// unzip content of a zip to given folder.content of the zip will be preserved (-keep yes).Destination will be overwritten (-force yes)
call zipjs.bat unzip -source C:\myDir\myZip.zip -destination C:\MyDir -keep yes -force yes