遍历子文件夹,FSO好象没这个功能
调用批处理命令dir /a:d/s/b- set objWsh = CreateObject("Wscript.Shell")
- Set objExec = objwsh.Exec("cmd.exe /c dir /a:d/s/b d:\1")
- Do Until objExec.StdOut.AtEndOfStream
- Call xcopy(objExec.StdOut.ReadLine)
- Loop
-
- Sub xcopy(pathB)
- If pathB = "" Then Exit Sub
- Dim PathA, PathC, FSO, File
- PathA = "c:\A"
- PathC = "c:\C"
- Set FSO = CreateObject("Scripting.FileSystemObject")
- If Not FSO.FolderExists(PathC) Then FSO.CreateFolder(PathC)
- For Each File In FSO.GetFolder(PathB).Files
- If Not FSO.FileExists(PathA &"\" & File.Name) Then
- File.Copy PathC &"\"
- End If
- Next
- MsgBox pathB & " OK"
- End Sub
复制代码 其实可以直接用批处理命令xcopy |