techcnb
asked on
Extract specific file from a group of .zip files
I would like to extract a specific file from a folder full of .zip files.
Each .zip file contains a text file that's file name begins with RTC
The following code will extract all the documents out of each zip folder, however i only want the RTC...file. Any help would be appreciated.
Heres what i have so far
Option Explicit
Dim objFSO, objShell, strFolder, objFile, strSource, strDestination
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objShell = CreateObject("WScript.Shel l")
strFolder = "C:\Temp"
For Each objFile In objFSO.GetFolder(strFolder ).Files
If Right(LCase(objFile.Name), 4) = ".zip" Then
strSource = objFile.Path
strDestination = "C:\Unzipped"
'Extract the Zip file into Directory
Extract strSource, strDestination
End If
Next
MsgBox "Done"
'Zip Extraction sub
Sub Extract(ByVal myZipFile, ByVal myTargetDir)
Dim strUZip, strCommand
strUZip = "N:\Utilities\UltimateZip Command Line Tool\uzext.exe"
If Right(myTargetDir, 1) <> "\" Then myTargetDir = myTargetDir & "\"
If objFSO.FolderExists(myTarg etDir) = False Then objFSO.CreateFolder(myTarg etDir)
strUZip = objFSO.GetFile(strUZip).Sh ortPath
myZipFile = objFSO.GetFile(myZipFile). ShortPath
myTargetDir = objFSO.GetFolder(myTargetD ir).ShortP ath
strCommand = "cmd /c " & strUZip & " -e -o -d -p" & myTargetDir & " " & myZipFile
objShell.Run strCommand, 0, True
End Sub
Each .zip file contains a text file that's file name begins with RTC
The following code will extract all the documents out of each zip folder, however i only want the RTC...file. Any help would be appreciated.
Heres what i have so far
Option Explicit
Dim objFSO, objShell, strFolder, objFile, strSource, strDestination
Set objFSO = CreateObject("Scripting.Fi
Set objShell = CreateObject("WScript.Shel
strFolder = "C:\Temp"
For Each objFile In objFSO.GetFolder(strFolder
If Right(LCase(objFile.Name),
strSource = objFile.Path
strDestination = "C:\Unzipped"
'Extract the Zip file into Directory
Extract strSource, strDestination
End If
Next
MsgBox "Done"
'Zip Extraction sub
Sub Extract(ByVal myZipFile, ByVal myTargetDir)
Dim strUZip, strCommand
strUZip = "N:\Utilities\UltimateZip Command Line Tool\uzext.exe"
If Right(myTargetDir, 1) <> "\" Then myTargetDir = myTargetDir & "\"
If objFSO.FolderExists(myTarg
strUZip = objFSO.GetFile(strUZip).Sh
myZipFile = objFSO.GetFile(myZipFile).
myTargetDir = objFSO.GetFolder(myTargetD
strCommand = "cmd /c " & strUZip & " -e -o -d -p" & myTargetDir & " " & myZipFile
objShell.Run strCommand, 0, True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
To:
Open in new window