|
Sub limonet()
Dim WSHShell As Object, Arr As Variant, ArrT As Variant, i%, F$, Path$
For Each a In CreateObject("Scripting.FileSystemObject").GetFolder(ThisWorkbook.Path).subfolders
F = a.Name
Next a
Path = ThisWorkbook.Path & "\" & F
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.CurrentDirectory = Path
Arr = Split(WSHShell.Exec("Powershell get-childitem -recurse -file -Include *清单.xls? | select name").StdOut.ReadAll, Chr(13) & Chr(10))
WSHShell.Run "Powershell get-childitem -recurse -file -Include *清单.xls? -name | copy-item -Destination (md out)", 0, True
For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
ArrT = Filter(Arr, Cells(i, "B"))
If UBound(ArrT) = -1 Then
Cells(i, "D") = "无文件"
Else
Cells(i, "D") = "已复制"
Cells(i, "H") = ArrT(0)
Name Path & "\out\" & Cells(i, "H") As Path & "\out\!" & Cells(i, "A") & "-" & Cells(i, "B") & "!" & Cells(i, "C") & "!" & F & "!.xlsx"
End If
Next i
End Sub |
评分
-
1
查看全部评分
-
|