Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Renaming Folders
Is there a way to rename all files and folders within a directory to
all lower case letters (while keeping the same name)? Thanks, -- Dan |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Renaming Folders
Try something like the following. It renames each folder to begin with "___"
and then renames again to the lower case name. This assumes you have no folders whose name begins with "___". Change C_FOLDER_NAME to the full name of the folder whose subfolder are to be renamed. Const C_FOLDER_NAME = "C:\Test" '<<< CHANGE Dim FSO As Object Dim TempName As String Dim FolderObj As Object Set FSO = CreateObject("Scripting.FileSystemObject") For Each FolderObj In FSO.GetFolder(C_FOLDER_NAME).SubFolders TempName = LCase(FolderObj.Name) FolderObj.Name = "___" & FolderObj.Name FolderObj.Name = TempName Next FolderObj Set FSO = Nothing -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Dan R." wrote in message ups.com... Is there a way to rename all files and folders within a directory to all lower case letters (while keeping the same name)? Thanks, -- Dan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Renaming Folders
Wow, very impressive, I wasn't expecting any feedback on this one...
Thanks a lot Chip, -- Dan |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Renaming Folders
Dan,
I didn't read your original post quite right. The code I replied with will only do one level of subfolders below the C_FOLDER_NAME, and it won't do files. The code below will rename all files and all levels of subfolders. As before, change C_FOLDER_NAME to the appropriate folder name, and run StartRename. It will call DoOneFolder and that calls itself recursively to do all files and all levels of subfolders. Sub StartRename() Const C_FOLDER_NAME = "C:\Test" Dim FSO As Object Dim TopFolder As Object Set FSO = CreateObject("Scripting.FileSystemObject") Set TopFolder = FSO.getfolder(C_FOLDER_NAME) DoOneFolder TopFolder End Sub Sub DoOneFolder(FolderObj As Object) Dim FileObj As Object Dim SubFolderObj As Object Dim LCName As String For Each FileObj In FolderObj.Files LCName = LCase(FileObj.Name) FileObj.Name = "___" & FileObj.Name FileObj.Name = LCName Next FileObj For Each SubFolderObj In FolderObj.subfolders LCName = LCase(SubFolderObj.Name) SubFolderObj.Name = "___" & SubFolderObj.Name SubFolderObj.Name = LCName DoOneFolder SubFolderObj Next SubFolderObj End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Dan R." wrote in message ups.com... Wow, very impressive, I wasn't expecting any feedback on this one... Thanks a lot Chip, -- Dan |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Renaming Folders
Perfect, works great!
Thanks again, -- Dan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i use vba to zip folders? | Excel Programming | |||
List of Folders | Excel Programming | |||
Renaming folders and changing links accordingly | Excel Programming | |||
Trouble renaming Folders | Excel Programming | |||
Renaming folders | Excel Programming |