All pastes #917774 Raw Edit

Unnamed

public text v1 · immutable
#917774 ·published 2008-02-25 17:43 UTC
rendered paste body
Set oFSO = CreateObject("Scripting.FileSystemObject")
oVidFolder = "ProClips"         'Video Recording Directory for WitnessPro
oDestFolder = "C:\Snapshots"    'Where the snapshots are kept
 
 
'Find the full path of oVidFolder
 
for each drive in oFSO.drives
   if drive.IsReady then
        oVidPath = drive.DriveLetter & ":\" & oVidFolder
        if oFSO.folderexists(oVidPath) then
        oVidFolder = oFSO.GetFolder(oVidPath)

	end if
   end if
next

    For Each Subfolder in oVidFolder.SubFolders
        Set oFolder = oFSO.GetFolder(Subfolder.Path)
if datevalue(oFolder.DateCreated) = datevalue(date) then
          sNewestFile = GetNewestFile(oFolder)
          sFName = oFSO.GetBaseName(sNewestFile)
            Set oShell = CreateObject("WScript.Shell")
             sShellCmd = "c:\windows\ffmpeg -i " & sNewestFile & " -y -f mjpeg -s 320x240 -vframes 1 " & oDestFolder & sFName & ".jpg"
         oShell.run(sShellCmd)
end if
Next

        
 
 
'This is the function that finds the newest file in the folder
Function GetNewestFile(ByVal oFolder)
 
   sNewestFile = Null   ' init value
   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oFolder = oFSO.GetFolder(oFolder)
   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
       dPrevDate = oFile.DateLastModified
     End If
     On Error Goto 0
   Next
   If IsNull(sNewestFile) Then sNewestFile = ""
   GetNewestFile = sNewestFile
 
End Function