如果输入文件夹中存在A列中指定的文件,我编写了从A列读取文件名并将其重命名为B列的代码。
Sub Rename_click()
Dim inputFolder$, iFile$, oFile$
Dim iRow&, lRow&
inputFolder = ThisWorkbook.Path & Application.PathSeparator & "Input"
With shInput
If .FilterMode Then .ShowAllData
lRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For iRow = 2 To lRow
iFile = .Cells(iRow, "A")
oFile = .Cells(iRow, "B")
If iFile <> "" And oFile <> "" Then
If Dir(inputFolder & Application.PathSeparator & iFile) <> "" Then
Name inputFolder & Application.PathSeparator & iFile As inputFolder & Application.PathSeparator & oFile
End If
End If
Next
End With
End Sub
适用于Windows。如何使Mac兼容?