Я хотел бы просмотреть все мои подпапки и переименовать их в «пример».Я не знаю имен папок всех моих подпапок.Мой код не работает вообще.
Пример структуры папки:
Main Folder >Subfolder A > Subfolder 1 (Rename this)
>Some file
>Subfolder B > Subfolder 2 (Rename this)
>Some file
>...
Вот код:
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