我正在尝试编写一个脚本,将文件从文件夹 A 复制到文件夹 B,它只会复制来自列表文件的文件。
然后我需要它来记录任何无法复制的文件。这是我到目前为止所拥有的,我只是无法让日志记录工作。
Option Explicit
Dim Sour, Dest
Dim oFSO, sFile, oFile, sText
Dim objFSO, objFileCopy
Dim strFilePath, strDestination, strSource
Const ForReading = 1, ForWriting = 2, ForAppending = 8
strLoggingFiles = "C:\failedtransfer.txt"
strSource = InputBox("Enter source path information") 'Enter your source path here
strDestination = InputBox("Enter destination path information") 'Enter your destination path here
'Set the read of the input file and prompt for location
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = InputBox("Enter path to text document with files to be copied:")
'Open the read, get the file name of the file to be copied, and copy it to new location
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, ForReading)
Do While Not oFile.AtEndOfStream
sText = oFile.ReadLine
If (Trim(sText) <> "") And _
oFSO.FileExists(strSource & "\" & sText) Then
oFSO.CopyFile strSource & "\" & sText, strDestination
Else
WScript.Echo "Couldn't find " & strSource & "\" & sText
End If
Loop
oFile.Close
Else
WScript.Echo "The file was not there."
End If