使用VBS将多个文本文件复制到多个位置

时间:2016-03-07 15:01:29

标签: vbscript

我想从一个位置复制配置文件并将其覆盖到另一个位置。下面是我的示例脚本,有人可以帮我解决这个问题吗?

.test {
   // another styles..
   width: 130px; //small width for test
   display: inline-block;
   vertical-align: middle;
}

1 个答案:

答案 0 :(得分:1)

有点不清楚的问题。但是,在下一个评论代码段中描述了基本改进:

''' disable error handling; show error and stop instead
On Error GoTo 0

Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")

strFileToCopy = "C:\Users\newtons\Desktop\Strat App 4 point to Pan 3.txt" 
strFolder = "C:\Users\newtons\Desktop\test\" 

If objFSO.FolderExists(strFolder) Then
    objFSO.CopyFile strFileToCopy, strFolder, OverwriteExisting  
Else
    Wscript.Echo "Target Folder does not exist."
End If

strFileToCopy = "C:\Users\newtons\Desktop\Stat App 4 point to Pan 3.txt" 
strFolder = "C:\Users\newtons\Desktop\test 2\" 

''' you cannot redefine a constant value
''' Const OverwriteExisting = TRUE
''' you need not redefine a variable to the same value
''' Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists(strFolder) Then
    objFSO.CopyFile strFileToCopy, strFolder, OverwriteExisting  
Else
    Wscript.Echo "Target Folder does not exist."
End If

Wscript.Echo "App 4 is now pointing to Pan 3"