我发现了这个 VBS 脚本,它将 Planeplotter(记录飞机的软件)中的数据记录到 CSV 文件中。
现在我的问题是:如何修改此脚本以每天创建一个新的 CSV 文件。现在一切都塞在一个文件中。
' PlanePlotter script for logging active aircraft (including those received by sharing)
' Create a file in the Log Files directory
Dim fso, f1, ts
Const ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateTextFile ("B:\_Mijn Downloads en Werkmap\_Spotten\PlanePlotter\Log\pp_share_log.txt")
Set f1 = fso.GetFile("B:\_Mijn Downloads en Werkmap\_Spotten\PlanePlotter\Log\pp_share_log.txt")
Set ts = f1.OpenAsTextStream(ForWriting, True)
' Tap in to PlanePlotter
Dim MyObject
Set MyObject = GetObject(,"PlanePlotter.Document")
' Write all the aircraft data out to file every minute for 24 hours
while 1
i = 0
while i < MyObject.GetPlaneCount()
hexc = MyObject.GetAllPlaneData(i,0)
regc = MyObject.GetAllPlaneData(i,1)
flnc = MyObject.GetAllPlaneData(i,2)
latf = MyObject.GetAllPlaneData(i,3)
latc = Cstr(latf)
latc = Replace(latc,",",".")
lonf = MyObject.GetAllPlaneData(i,4)
lonc = CStr(lonf)
lonc = Replace(lonc,",",".")
altf = MyObject.GetAllPlaneData(i,5)
altc = CStr(altf)
altc = Replace(altc,",",".")
hedf = MyObject.GetAllPlaneData(i,6)
hedc = CStr(hedf)
hedc = Replace(hedc,",",".")
spdf = MyObject.GetAllPlaneData(i,7)
spdc = CStr(spdf)
spdc = Replace(spdc,",",".")
recc = MyObject.GetAllPlaneData(i,8)
recc = Replace(recc," ",",") ' put a comma half way through
icao = MyObject.GetAllPlaneData(i,14)
shar = MyObject.GetAllPlaneData(i,18)
verr = MyObject.GetAllPlaneData(i,21)
verc = CStr(verr)
planeinfo = recc + "," + hexc + "," + regc + "," + flnc + "," + icao + "," + altc + "," + latc + "," + lonc + "," + spdc + "," + hedc + "," + shar + "," + verc + ","
ts.WriteLine (planeinfo)
i = i + 1
wend
ts.WriteLine ("---------")
Wscript.Sleep 180000 ' 60 Seconds
n = n - 1
wend
ts.Close