我现在的一个文件夹内有若干个图片,其文件名为类似于:250155122_调整图片.jpg,35115521585115x_整图片.jpg,现在我要批量重命名为:250155122.jpg,35115521585115x.jpg等等(即去除"_调整图片"这几个字),请问我用VB要怎么写啊,谢谢

解决方案 »

  1.   

    '引用FSO("工程"->"引用"->Microsoft Scripting Runtime)Private Sub Command1_Click()
        SearchFolder "d:\test\"  '假设你的图片放在D:\test\文件夹下
    End SubSub SearchFolder(ByVal Folder As String)
        Dim fso As New FileSystemObject
        Dim objFile As File, objFolder As Folder
        
        Set objFolder = fso.GetFolder(Folder)
        For Each objFile In objFolder.Files
            reNameFile objFile.Path
        Next
    End SubSub reNameFile(ByVal fullName As String)
        Dim newName As String, pos As Integer
        pos = InStrRev(fullName, "\")
        newName = Mid(fullName, 1, pos) & Replace(Mid(fullName, pos + 1), "_调整图片", "")
        Name fullName As newName
    End Sub