Set FSO = CreateObject("Scripting.FileSystemObject") Set regEx = New RegExp sPath = Wscript.Arguments(0) Set tsR = FSO.OpenTextFile(sPath) sLines = Split(tsR.ReadAll, vbNewLine) tsR.Close Set tsW = FSO.CreateTextFile(sPath) For l = 0 To Ubound(sLines) - 1 tsW.WriteLine AddNum(sLines(l)) Next tsW.Close Set FSO = Nothing Wscript.Quit
Set arg = Wscript.Arguments If arg.Count > 0 Then Set FSO = CreateObject("Scripting.FileSystemObject") Set regEx = New RegExp For Each oItm In arg If FSO.FileExists(oItm) Then Call FileRename(oItm) ElseIf FSO.FolderExists(oItm) Then Select Case FolderRename Case 1 Set oFolder = FSO.GetFolder(oItm) oFolder.Name = AddNum(oFolder.Name) Case 2 For Each oFile In FSO.GetFolder(oItm).Files Call FileRename(oFile.Path) Next End Select End If Next Set FSO = Nothing End If Wscript.Quit
Sub FileRename(sPath) FSO.GetFile(sPath).Name = AddNum(FSO.GetBaseName(sPath)) & "." & FSO.GetExtensionName(sPath) End Sub