|
Sub 按钮1_Click()
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show Then pth = .SelectedItems(1) Else Exit Sub
End With
If Right(pth, 1) <> "\" Then pth = pth & "\"
Set d = CreateObject("scripting.dictionary")
Set fso = CreateObject("scripting.filesystemobject")
arr = [a1].CurrentRegion
For Each f In fso.getfolder(pth).Files
d(Split(f.Name, ".")(0)) = f
Next f
r = 0
For j = 3 To UBound(arr)
If d.exists(arr(j, 2)) Then
r = r + 1
arr(j, 5) = arr(j, 2) & "-" & Format(r, "000")
Name d(arr(j, 2)) As pth & "\" & arr(j, 5) & ".jpg"
End If
Next j
[a1].CurrentRegion = arr
End Sub |
|