在如何更改下面的脚本以使用相对路径方面我可能会使用一些帮助,我似乎无法将自己的头围住如何到达它。我也只是在学习如何编写VB脚本,因此整件事可能不是实现我想要的最佳方法。脚本通过.csv查找字符串,然后在新文档中放置一个值以列出要复制的文件。同样,如果有人能指出正确的方向,以便它找到第一个字符串,那么脚本将继续搜索其他字符串,而不仅仅是在找到第一个字符串时停止并打印文本。>
Const ForReading = 1
Const TristateFalse = 0
Dim strSearchThis
Dim objFSO
Dim objFolder
Dim objFile, objFileList
Folder = "G:\Color Standards Scripts\Line 1\File List\" ' change to the path of your files
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(Folder) Then
Set objFolder = objFSO.GetFolder(Folder)
Set objFileList = objFolder.Files
For Each objFile in objFileList
strFileName = objFile.Name
Set objTS = objFile.OpenAsTextStream( ForReading, TristateFalse )
strSearchThis = objTS.READ( objFile.Size )
If InStr( strSearchThis, "703,A" ) Then 'Change "Search String" to what you need to search fo
Set OutPutFile = objFSO.OpenTextFile("G:\Color Standards Scripts\Line 1\File List\File-list-Line1.txt" ,8 , True)
OutPutFile.WriteLine("703A.xlsm")
Set objFSO= Nothing
Else
WScript.Echo "Did not find Search String!" ' and again here
End If
Next
Else
Set objFSO = Nothing
WScript.Quit
End If