Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Dim objFSO, objFolder, objShell, objTextFile, objFile, objWMIService, objLatestEvent, objFilename, colMonitoredEvents
- Dim strFile, strText, strTsplit, strComputer, strNewFile, arrNewFile, strNewFileExt, strNewRecFile, strNewRecFileName, monFolder
- Dim debug, ret, binTsplit, outDir, strTsplitCli
- '--------------------------------------------------------------------------------------------------
- 'variables to change
- 'debug mode on = 1, debug mode off = 0
- debug = 1
- 'folder to monitor for new transport streams
- monFolder = "D:\TS"
- 'path to TSSplitter wrapper batch, should be where mondir.vbs is located
- binTsplit = "D:\STools\autostrip\tssplitter.bat"
- '--------------------------------------------------------------------------------------------------
- 'main monitoring code starts here
- Wscript.Echo "Now monitoring " & monFolder & "..."
- Wscript.Echo ""
- strTsplit = """" & binTsplit & """ "
- monFolder = Replace(monFolder, "\", "\\\\")
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" & _
- strComputer & "\root\cimv2")
- Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
- ("SELECT * FROM __InstanceCreationEvent WITHIN 15 WHERE " _
- & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
- & "TargetInstance.GroupComponent= " _
- & "'Win32_Directory.Name=""" & monFolder & """'")
- Do
- Set objLatestEvent = colMonitoredEvents.NextEvent
- 'Wscript.Echo objLatestEvent.TargetInstance.PartComponent
- strFile = objLatestEvent.TargetInstance.PartComponent
- arrNewFile = Split(strFile, "=")
- strNewFile = arrNewFile(1)
- strNewFile = Replace(strNewFile, "\\", "\")
- strNewFile = Replace(strNewFile, Chr(34), "")
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- set objFilename = objFSO.GetFile(strNewFile)
- strNewFileExt = objFSO.GetExtensionName(objFilename)
- if debug > 0 Then
- Wscript.echo "Debug: New File Detected - " & objFilename
- Wscript.echo ""
- end if
- if strNewFileExt = "txt" Then
- strNewRecFile = objFSO.GetParentFolderName(objFilename) & "\" & objFSO.GetBaseName(objFilename) & ".ts"
- strNewRecFileName = objFSO.GetBaseName(objFilename) & ".ts"
- if objFSO.FileExists(strNewRecFile) then
- Wscript.echo "Recording Finished: " & strNewRecFileName
- Wscript.echo "Stripping 1SEG/SD..."
- Set objShell = CreateObject("Wscript.Shell")
- if debug > 0 Then
- Wscript.echo "Debug: " & strTsplit & """" & strNewRecFile & """"
- ret = objshell.run (strTsplit & """" & strNewRecFile & """")
- else
- ret = objshell.run (strTsplit & """" & strNewRecFile & """")
- end if
- Wscript.sleep(60000)
- end if
- elseif strNewFileExt = "ts" Then
- if InStr(objFSO.GetBaseName(objFilename), "_HD") = 0 Then
- Wscript.echo "New Recording Started: " & objFSO.GetBaseName(objFilename) & "." & objFSO.GetExtensionName(objFilename)
- end if
- end if
- Loop
Add Comment
Please, Sign In to add comment