'==============================================================================
'- ROUTINE TO *RENAME* SPECIFIED FOLDERS
'==============================================================================
'- ADAPT THE CODE FOUND IN http://www.mrexcel.com/forum/showthread.php?t=266783
'- REPLACE THE EXISTING SUB WITH THE ONE BELOW
'- This example changes folders called "09-08" to "08-09"
'- Brian Baulsom September 2008
'==============================================================================
'- ** This code is untested in its present state !!! **
'- I strongly suggest that you temporarily copy the "BaseFolder" folder and contents
'- to another location until you are sure that this works correctly !!!
'- Test a single folder first (Make "BaseFolder" a single folder)
'==============================================================================
'- SUBROUTINE : GET SUBFOLDERS OF SPECIFIED FOLDER
'- AMENDED TO CHANGE SPECIFIED FOLDER NAMES
'==============================================================================
Private Sub ShowFolderList(FolderSpec)
Dim f, f1, fc, s
Set f = FSO.GetFolder(FolderSpec)
Set fc = f.subfolders
'------------------------------
Dim NewFolderName As String
NewFolderName = "08-09"
'--------------------------------------------------------------------------
'- CHECK SUBFOLDER COUNT
If fc.Count = 0 Then
Exit Sub
Else
'--------------------------------------------------------------------------
'- LOOP FOLDERS
For Each f1 In fc
'==================================================================
'- CHECK FOLDER NAME
'==================================================================
FolderName = f1.path
Application.StatusBar = FolderName
'- CHANGE NAME
If FolderName = "09-08" Then
Name FolderName As NewFolderName ' change the folder name
End If
' MySheet.Cells(ToRow, 1).Value = FolderName ' DON'T NEED THIS LINE (?)
' ShowFileList (FolderName) ' DON'T NEED THIS LINE (?)
'==================================================================
'- CALL SELF TO GET ANY SUBFOLDERS IN THIS SUBFOLDER
ShowFolderList (FolderName)
'-------------------------------------------------------------------
Next
End If
'---------------------------------------------------------------------------
End Sub
'== END OF SUB =================================================================