我正在使用下面的Robocopy脚本。我想知道的是,有一种方法可以在镜像操作期间排除以com_而不是特定文件开头的所有文件。 任何建议都非常感谢。
Const ROBOCOPY_PARMS_MIRROR = "/mir /r:1 /w:3 /np /xa:SH /tee /np"
Const ROBOCOPY_PARMS_EXCLUDE_DIR = "bin"
Const ROBOCOPY_PARMS_EXCLUDE_FILE = "com_.txt"
Const sourcePath = "C:\copy1"
Const destinationPath = "C:\copy"
roboCopyParms = ROBOCOPY_PARMS_MIRROR
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
cmd = "robocopy " & sourcePath & " " & destinationPath & " " & roboCopyParms & " /xd " & ROBOCOPY_PARMS_EXCLUDE_DIR & " /xf " & ROBOCOPY_PARMS_EXCLUDE_FILE
ret = WshShell.Run(cmd, 0, true)
WScript.Echo ret
由于
答案 0 :(得分:0)
解决方法是创建自己的robocopy脚本:
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
RoboCopy "C:\copy","C:\copy1"
Function RoboCopy(source,dest)
Set sourceFolder = fso.GetFolder(source)
If Not(fso.FolderExists(dest)) Then
fso.CreateFolder(dest)
End If
For Each file In sourceFolder.Files
If Left(file.Name,3)<>"com" Then
fso.CopyFile file.Path,dest & "\" & file.Name
End If
Next
For Each subfolder In sourceFolder.SubFolders
RoboCopy source & "\" & subfolder.Name,dest & "\" & subfolder.Name
Next
End Function