The FileSystemObject has a method .GetFile(FileSpec) that returns an object for the file FileSpec. Those objects have a (writable) .Name property. So get the .Name, modify it, and write/assign the new one.
To give you some ideas (looping over the files in a folder, finding the file(s) to change, extracting the number to increment):
Option Explicit
Dim goFS : Set goFS = CreateObject( "Scripting.FileSystemObject" )
WScript.Quit demoMain()
Function demoMain()
demoMain = 0 ' assume success
Dim sDDir : sDDir = goFS.GetAbsolutePathName(".")
Dim reVictim : Set reVictim = New RegExp
reVictim.IgnoreCase = True
reVictim.Pattern = "^(victim)(d+)(.txt)$"
Dim oFile
For Each oFile In goFS.GetFolder(sDDir).Files
If reVictim.Test(oFile.Name) Then
WScript.Echo "found: ", oFile.Name
oFile.Name = reVictim.Replace(oFile.Name, GetRef("FINC"))
WScript.Echo "renamed:", oFile.Name
End If
Next
End Function ' demoMain
Function FINC(sM, sG1, sG2, sG3, nP, sS)
FINC = sG1 & Right(100 + sG2 + 1, 2) & sG3
End Function
output:
cscript finc.vbs
found: victim00.txt
renamed: victim01.txt
cscript finc.vbs
found: victim01.txt
renamed: victim02.txt
cscript finc.vbs
found: victim02.txt
renamed: victim03.txt
How to copy with overflow of the counter is left as exercise.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…