|
Dim FSO As Object, a(1 To 10 ^ 4, 1 To 3), s
Sub test1()
Dim i, oldpathname, newpathname
Set FSO = CreateObject("scripting.filesystemobject")
test2 ThisWorkbook.Path
'
For i = 1 To s
If InStr("bmp,jpg,tif,png", a(i, 3)) Then
oldpathname = a(i, 1) & a(i, 2) & "." & a(i, 3)
newpathname = a(i, 1) & a(i, 2) & "." & "gif"
Name oldpathname As newpathname
End If
Next i
End Sub
'
Sub test2(MyPath As String)
Dim Folder As Object, SubFolder As Object
Dim FileCollection As Object, FileName As Object
'
Set Folder = FSO.getfolder(MyPath)
Set FileCollection = Folder.Files
For Each FileName In FileCollection
s = s + 1
a(s, 1) = MyPath & "\"
a(s, 2) = FSO.GetBaseName(MyPath & FileName)
a(s, 3) = FSO.GetExtensionName(MyPath & FileName)
Next
'
For Each SubFolder In Folder.SubFolders
test2 SubFolder.Path
Next
End Sub
批量更改后缀2.rar
(721.31 KB, 下载次数: 15)
|
|