Question:
Can I extract a ZIP file via scripts?
Can I extract a ZIP file via scripts?
Solution:
Yes, you can. For example:
‘ZIP file to be extracted:
pathToZipFile=”C:\Folder1\MyZIPfile.zip”
‘Folder of destination:
extractTo=”C:\Folder2\”
‘Tests if the file exists
set fso2 = CreateObject(“Scripting.FileSystemObject”)
if fso2.FileExists(pathToZipFile) = FALSE then
MsgBox “The file does not exist!”
exit sub
end if
‘Tests if the folder exists
if fso2.FolderExists(extractTo) = FALSE then
MsgBox “The folder does not exist!”
exit sub
end if
‘Extracts the file
Set SA = CreateObject(“Shell.Application”)
Set filesInzip=SA.NameSpace(pathToZipFile).items
SA.NameSpace(extractTo).CopyHere(filesInzip)