1
我的oldfile创建一个新的文件看起来像FolderList.txt
与内容:如何在旧的文件搜索特定的文本
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20140825_123400
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20140827_065126
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20141006_094447
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20141006_110546
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20141008_105947
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20150917_093710
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20151005_190254
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20151005_191124
我想创建一个名字FolderListNew.txt
一个新的文件和内容:
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20141006_110546
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20141008_105947
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20150917_093710
\\srv10177\temppahir$\Desktop\WORK\6758\Archive\Article\20151005_190254
所以基本上我想做一个搜索2文本:
Text1 = 20141006_110546
Text2 = 20151005_190254
和从第一次出现Text1
拉行,直到出现Text2
。 假设数据总是像这样,并按照这些时间戳按升序排列。
我曾尝试下面的脚本,不工作,不完整:
Option Explicit
Dim objFSO, msg, Filename, file, filestreamOUT, objFile, strContents, strLine, line, Text1, Text2, OLDFilename, tmpStr, MyPos
Set objFSO = CreateObject("Scripting.FileSystemObject")
Text1 = "20141006_110546"
Text2 = "20151005_190254"
OLDFilename="C:\Users\IBM_ADMIN\Desktop\VB\Folderlist.txt"
WScript.Echo "String to find is : " & Text1
Wscript.Echo "OLDFilename is " & OLDFilename
Set objFile = objFSO.OpenTextFile(OLDFilename, 1)
Wscript.Echo "Reading file the first time:"
strContents = objFile.ReadAll
Wscript.Echo "Line being read is" & strContents
WScript.Echo "tmpStr.ReadLine is : " & Line
'MyPos = InStr (tmpStr.ReadLine, Text1)
WScript.Echo "MyPos value is : " & MyPos
If MyPos >= 0 Then
'WScript.Echo "Match NOT Found in File and tmpStr.ReadLine is : " & tmpStr.ReadLine
Else
WScript.Echo "string value is : " & strLine
WScript.Echo "Match Found in File and tmpStr.ReadLine is : " & tmpStr.ReadLine
End If
我是vb脚本的新手。我仍然尝试了一些东西,例如.. – pals
我无法将整个脚本放在适当的格式中。我想这是VB脚本。如果我错了,请纠正我。 – pals
@ simonalexander2005 - 我无法将我的脚本放在适当的格式中。我已经在上面发布了Watever,它是否可读? – pals