|
Option Explicit
Sub test()
Dim ar, d As Object, fso As Object, f, fld, p$, lr&, i%
Set d = CreateObject("scripting.dictionary")
Set fso = CreateObject("scripting.filesystemobject")
p = ThisWorkbook.Path & "\"
lr = [a65536].End(xlUp).Row
ar = [a1].Resize(lr, 2)
For i = 2 To lr
d(ar(i, 1) & "") = ar(i, 2)
Next
For Each f In fso.GetFolder(p).Files
If InStr(f.Name, ".xl") And f.Name <> ThisWorkbook.Name And Left(f.Name, 2) <> "~$" Then
If d.Exists(Split(f.Name, ".xl")(0) & "") Then
fld = p & d(Split(f.Name, ".xl")(0) & "")
If Not fso.FolderExists(fld) Then fso.CreateFolder (fld)
If fso.FileExists(fld & "\" & f.Name) Then
fso.MoveFile f, fld & "\(副本)" & f.Name
Else
fso.MoveFile f, fld & "\" & f.Name
End If
End If
End If
Next
Set d = Nothing
Set fso = Nothing
End Sub |
评分
-
1
查看全部评分
-
|