call RemoveblankSpace_Subfolders("D:\TextTest")
''strbasefoldername - Folder Path in which file needs to be replaced
Public Function RemoveblankSpace_Subfolders(strbasefoldername)
On error resume next
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFolder
For Each objSubFolder In objFSO.GetFolder(strbasefoldername).SubFolders
FlderName = objSubFolder.Name
FlderName = replace(FlderName," ","")
objSubFolder.Name = FlderName
Next
Set objSubFolderFolder = Nothing
Set objFSO = Nothing
End Function
call Rename_Subfolders("D:\TextTest","es","twist",false,"test")
'' strbasefoldername - Folder Path in which file needs to be replaced
'' strFindtext - text in the folder name that needs to be replaced
'' strReplaceText - new text to replace the existing test
'' boolAllFlders - boolean flag to indicate if all the subfolder needs to be renamed or
'' specific folders needs to be renamed
'' OnlyfoldersWithText - replace only folder with specific text. will consider only if
'' boolAllFlders =true
Public Function Rename_Subfolders(strbasefoldername,strFindtext,strReplaceText,boolAllFlders,OnlyfoldersWithText)
On error resume next
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFolder
For Each objSubFolder In objFSO.GetFolder(strbasefoldername).SubFolders
FlderName = objSubFolder.Name
if boolAllFlders = false then
if(instr(1,FlderName,OnlyfoldersWithText)>0) then
FlderName = replace(FlderName,strFindtext,strReplaceText)
objSubFolder.Name = FlderName
End If
else
FlderName = replace(FlderName,strFindtext,strReplaceText)
objSubFolder.Name = FlderName
End If
Next
Set objSubFolderFolder = Nothing
Set objFSO = Nothing
End Function