My project involves downloading huge numbers of folders from a website, all of which are zipped, and then processing the data.
The macros I found for unzipping folders require specific paths to and from, while I need something that will unzip all of the folders within a specified folder - while keeping them organized by folder name. They can unzip to the same folder, they could even overwrite the zip file (in this case it wouldn't matter), but they must stay organized by folder name - otherwise the processing portion won't work.
I have two problems:
one - I have to select all the folders (to get paths), rather than just unzipping all the folders.
I tried modifying to run through each subfolder but it doesn't "see" zipped folders without a path, same issue with Dir().
two - it dumps all the unzipped files into a single destination, making it useless for processing.
A macro that does the same as right click, "extract all", but loops through all folders within a folder, would be perfect.
Sub Button11_Click()
Dim IPath, OPath As String, FFile, FFSo, FFolder As Object
Dim oApp As Object
Dim Fname As Variant
Dim Output_Folder As Variant
Dim strDate As String
Dim i As Long
IPath = "E:\R2\Input\Zipped\"
OPath = "E:\R2\Input\"
'Select multiple zip files to unzip
MsgBox "Go to E:\R2\Input\Zipped\ - For Zipped folders"
Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _
MultiSelect:=True)
If IsArray(Fname) = False Then
'Do nothing
Else
'For Each SFolder In AFolder.Subfolders
'Set output folder path for unzip files
Output_Folder = OPath
'Extract the files into output folder
Set oApp = CreateObject("Shell.Application")
For i = LBound(Fname) To UBound(Fname)
'WORKS BUT DOESN"T SEPARATE INTO FOLDERS, just dumps into input folder.
oApp.Namespace(Output_Folder).CopyHere oApp.Namespace(Fname(i)).items
Next i
MsgBox "You find the files here: " & Output_Folder
End If
End Sub