我有一个文件夹,其中包含许多其他文件夹,其中包含我需要重命名的 csv 文件
我目前有这个不起作用
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
此脚本适用于单级:
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