|
Sub 处理文件()
With ThisWorkbook.Sheets(1)
.[a1] = "原文件名"
.[b1] = "新文件名"
.Range("a2:a" & .Cells(Rows.Count, 1).End(xlUp).Row + 1).Clear
End With
dz = ThisWorkbook.Path
遍历 (dz)
End Sub
Sub 遍历(x)
Dim fd1 As Folder, fd2 As Folder, f As File
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = ThisWorkbook.Sheets(1)
Set fd1 = fso.GetFolder(x)
For Each f In fd1.Files
If Not f.Name Like "*" & ThisWorkbook.Name & "*" Then
hh = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("a" & hh) = fd1 & "\" & f.Name
Name ws.Range("a" & hh).Value As ws.Range("a" & hh).Offset(0, 1).Value
End If
Next f
For Each fd2 In fd1.SubFolders
遍历 (fd2)
Next fd2
End Sub
|
评分
-
1
查看全部评分
-
|