标签:term 技术 info Fix 字符 init rmi UNC prefix
原图
修改后
‘批量修改文件名.vbs
Function GetScriptPath()
GetScriptPath = Left(WScript.ScriptFullName, Len(WScript.ScriptFullName) - Len(WScript.ScriptName))
End Function
Class MyFileOperator
Private obj
Private Sub Class_Initialize()
Set obj = CreateObject("Scripting.FileSystemObject")
End Sub
Private Sub Class_Terminate()
Set obj = Nothing
End Sub
‘ 枚举文件
Public Function ListFiles()
Dim path :path = GetScriptPath()
Dim objFolder : Set objFolder = obj.GetFolder(path)
Dim files()
Dim i :i = 0
For Each objFile in objFolder.Files
ReDim Preserve files(i)
files(i) = objFile.Name
i = i + 1
Next
Set objFolder = Nothing
ListFiles = files
End Function
‘ 文件改名
Public Sub ChangeFileName(source, dest)
Call obj.MoveFile(source, dest)
End Sub
End Class
Dim fop :Set fop = New MyFileOperator
Dim files :files = fop.ListFiles() ‘
Dim prefix : prefix = InputBox("请输入文件名前缀:") ‘获取用户输入的前缀
Dim suffix : suffix = InputBox("请输入文件名后缀:") ‘获取用户输入的后缀
Dim i
‘更改名称
For i = 1 To UBound(files)
Call fop.ChangeFileName(files(i), prefix &"-"& i &"."& suffix)
Next
&
是字符连接符prefix &"-"& i &"."& suffix
就是要改的名字,不需要—
可以直接删除标签:term 技术 info Fix 字符 init rmi UNC prefix
原文地址:https://www.cnblogs.com/MrFlySand/p/15021486.html