I have a folder that contains many other folders with csv files within them that I need to rename
I currently have this that does not work
Set Fso = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("C:\Temp\AMLReports\")
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Wscript.Echo Subfolder.Path
ShowSubFolders Subfolder
sNewFile = File.Name
sNewFile = Replace(sNewFile,"OLDNAMEPART","NEWNAMEPART")
if (sNewFile<>File.Name) then
File.Move(File.ParentFolder+"\"+sNewFile)
end if
Next
End Sub
This script works for single level :
Set objFso = CreateObject("Scripting.FileSystemObject")
Set Folder = objFSO.GetFolder("C:\Temp\AMLReports\")
For Each File In Folder.Files
sNewFile = File.Name
sNewFile = Replace(sNewFile,"oldpartname","new part name")
if (sNewFile<>File.Name) then
File.Move(File.ParentFolder+"\"+sNewFile)
end if