VB批量重命名文件代码
PrivateSubButton10_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesB...
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Dim FSO As Object, FDR As Object, F As Object, i As Object, OldName As String, NewName As String
FSO = CreateObject("Scripting.FileSystemObject") '创建计算机文件系统以向其访问()
FDR = FSO.GetFolder("D:/test") '指定其中访问的文件夹对象
F = FDR.Files '定义该文件夹中的所有文件集合
For Each i In F '在指定文件下的文件中循环
OldName = FDR & "/" & i.name
NewName = FDR & "/" & Mid(i.name, 3) '去掉前两个字符
FileSystem.Rename(OldName, NewName)
Next i
End Sub
为什么这段代码老是报错啊? 展开
Dim FSO As Object, FDR As Object, F As Object, i As Object, OldName As String, NewName As String
FSO = CreateObject("Scripting.FileSystemObject") '创建计算机文件系统以向其访问()
FDR = FSO.GetFolder("D:/test") '指定其中访问的文件夹对象
F = FDR.Files '定义该文件夹中的所有文件集合
For Each i In F '在指定文件下的文件中循环
OldName = FDR & "/" & i.name
NewName = FDR & "/" & Mid(i.name, 3) '去掉前两个字符
FileSystem.Rename(OldName, NewName)
Next i
End Sub
为什么这段代码老是报错啊? 展开
2个回答
展开全部
Mid(i.name, 3) 改 Mid(i.name, 3,len(i.name)-2)
更多追问追答
追问
大神,还是不行啊
追答
OldName = FDR.path & "/" & i.name
NewName = FDR.path & "/" & Mid(i.name, 3, Len(i.name) - 2) '去掉前两个字符
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询