Automatically publishing meteor images to the Internet using Windows Task Schedular and VB Script
The following will copy on a regular basis the files created by SpectrumLab to your website. A history of twelve images is kept on your server.
Create a script file such as copy_meteor.vbs and past the following text:
Option Explicit
Dim sOriginFolder, sDestinationFolder, sFile, sDate
Dim sNewestFile
Dim objFSO, objShell
' go get the latest file
Set objFSO = CreateObject("Scripting.FileSystemObject")
sDate = YEAR(Date()) & Pd(Month(date()),2) & pd(DAY(date()),2)
sOriginFolder = "c:\meteor\image\capture_" &sDate
sDestinationFolder = "c:\meteor"
sNewestFile = GetNewestFile(sOriginFolder)
objFSO.GetFile(sNewestFile).Copy sDestinationFolder & "\" & "1.jpg",True
' ftp the files
Set objShell = CreateObject("WScript.Shell")
objShell.Run "c:\windows\system32\ftp.exe -s:ftpput.txt", , True
Set objShell = Nothing
Function GetNewestFile(ByVal sPath)
Dim oFolder, oFiles, oFile
sNewestFile = Null ' init value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = objFSO.GetFolder(sPath)
Set oFiles = oFolder.Files
' enumerate the files in the folder, finding the newest file
For Each oFile In oFiles
On Error Resume Next
If IsNull(sNewestFile) Then
sNewestFile = oFile.Path
dPrevDate = oFile.DateLastModified
Elseif dPrevDate < oFile.DateLastModified Then
sNewestFile = oFile.Path
' This is the line missing previously:
dPrevDate = oFile.DateLastModified
End If
On Error Goto 0
Next
If IsNull(sNewestFile) Then sNewestFile = ""
GetNewestFile = sNewestFile
End Function
Function pd(n, totalDigits)
if totalDigits > len(n) then
pd = String(totalDigits-len(n),"0") & n
else
pd = n
end if
End Function
Next, create a file ftpput in the same folder and past the following text. Change adress, username and pasword to that of you own server.
open www.youradress.wonderland
username
pasword
cd whateverfolderyouwanttheimagesin
bin
rename 11.jpg 12.jpg
rename 10.jpg 11.jpg
rename 9.jpg 10.jpg
rename 8.jpg 9.jpg
rename 7.jpg 8.jpg
rename 6.jpg 7.jpg
rename 5.jpg 6.jpg
rename 4.jpg 5.jpg
rename 3.jpg 4.jpg
rename 2.jpg 3.jpg
rename 1.jpg 2.jpg
put 1.jpg
quit
No all there is left is to create a task in Windows Task Schedular that executes every 5 minutes. If SpectrumLab saves images quicker or slower, change the timing in Task Schedular too.