I would like to loop through all of my subfolders and rename them to "example". I don't know the folder names of all my subfolders. My code does not work at all.
Example of Folder Structure:
Main Folder >Subfolder A > Subfolder 1 (Rename this)
>Some file
>Subfolder B > Subfolder 2 (Rename this)
>Some file
>...
Here's the code:
Dim FSO As Object
Dim folder As Object
Dim subfolders As Object
Dim MyFile As String
Dim wb As Workbook
Dim CurrFile As Object
Dim NewFolderName As String
NewFolderName = "Photos"
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Set FSO = CreateObject("Scripting.FileSystemObject")
Set folder = FSO.GetFolder("C:\Users\Tom\Desktop\Test\SHeets\")
Set subfolders = folder.subfolders
For Each folder In folder.subfolders
subfoldersName = folder.Path
Application.StatusBar = subfoldersName
Name subfoldersName As FolderName & NewFolderName ' change the folder name
Next
Set FSO = Nothing
Set folder = Nothing
Set subfolders = Nothing
With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub