整的好复杂,不知道有没有简单方法。。。- PathA = "c:\A"
- PathB = "c:\B"
- PathC = "c:\C"
- Dim Str
- Set Ws = CreateObject("WScript.Shell")
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Str = GetFileStr(PathA)
- XcopyFile PathB
- MsgBox "OK"
-
- Sub XcopyFile(SubPath)
- For Each File In FSO.GetFolder(SubPath).Files
- Name = "|" & File.Name & "|"
- If InStr(LCase(Str),LCase(Name)) = 0 Then
- Name = PathC & Right(File.Path,Len(File.Path) - Len(PathB))
- Ws.Run "xcopy " & chr(34) & File.Path & chr(34) & " " &_
- chr(34) & Left(Name,InStrRev(Name,"\")) & chr(34) & " /s",0
- End If
- Next
- For Each Folder In FSO.GetFolder(SubPath).SubFolders
- XcopyFile Folder.Path
- Next
- End Sub
-
- Function GetFileStr(SubPath)
- For Each File In FSO.GetFolder(SubPath).Files
- Str = Str & File.Name & "|"
- Next
- For Each Folder In FSO.GetFolder(SubPath).SubFolders
- GetFileStr Folder.Path
- Next
- GetFileStr = "|" & Str
- End Function
复制代码
|