Extracting ZIP files via scripts.

Question:

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)

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *