apath=InputBox("Input root folder's full path") replaceFileName(apath)
Function replaceFileName(ByVal dPath) Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(dPath) Set oFiles = oFolder.Files set oSubFolders=oFolder.Subfolders For Each oFile In oFiles if instr(oFile.name,"&") then oFile.name= Replace(oFile.name,"&","_",1,-1,1) if instr(oFile.name,"%") then oFile.name= Replace(oFile.name,"%","_",1,-1,1) if instr(oFile.name,"?") then oFile.name= Replace(oFile.name,"?","_",1,-1,1) Next For Each subFolder In oSubFolders if instr(subFolder.name,"&") then subFolder.name= Replace(subFolder.name,"&","_",1,-1,1) if instr(subFolder.name,"%") then subFolder.name= Replace(subFolder.name,"%","_",1,-1,1) if instr(subFolder.name,"?") then subFolder.name= Replace(subFolder.name,"?","_",1,-1,1) replaceFileName(subFolder.path) Next End Function
|