Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Dim objFSO, objFolder, objShell, objTextFile, objFile, objWMIService, objLatestEvent, objFilename, colMonitoredEvents
  4. Dim strFile, strText, strTsplit, strComputer, strNewFile, arrNewFile, strNewFileExt, strNewRecFile, strNewRecFileName, monFolder
  5. Dim debug, ret, binTsplit, outDir, strTsplitCli
  6.  
  7. '--------------------------------------------------------------------------------------------------
  8. 'variables to change
  9.  
  10. 'debug mode on = 1, debug mode off = 0
  11. debug = 1
  12.  
  13. 'folder to monitor for new transport streams
  14. monFolder = "D:\TS"
  15.  
  16. 'path to TSSplitter wrapper batch, should be where mondir.vbs is located
  17. binTsplit = "D:\STools\autostrip\tssplitter.bat"
  18.  
  19. '--------------------------------------------------------------------------------------------------
  20. 'main monitoring code starts here
  21.  
  22. Wscript.Echo "Now monitoring " & monFolder & "..."
  23. Wscript.Echo ""
  24.  
  25. strTsplit = """" & binTsplit & """ "
  26.  
  27. monFolder = Replace(monFolder, "\", "\\\\")
  28. strComputer = "."
  29.  
  30. Set objWMIService = GetObject("winmgmts:" _
  31. & "{impersonationLevel=impersonate}!\\" & _
  32. strComputer & "\root\cimv2")
  33. Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
  34. ("SELECT * FROM __InstanceCreationEvent WITHIN 15 WHERE " _
  35. & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
  36. & "TargetInstance.GroupComponent= " _
  37. & "'Win32_Directory.Name=""" & monFolder & """'")
  38. Do
  39. Set objLatestEvent = colMonitoredEvents.NextEvent
  40. 'Wscript.Echo objLatestEvent.TargetInstance.PartComponent
  41.  
  42. strFile = objLatestEvent.TargetInstance.PartComponent
  43. arrNewFile = Split(strFile, "=")
  44. strNewFile = arrNewFile(1)
  45. strNewFile = Replace(strNewFile, "\\", "\")
  46. strNewFile = Replace(strNewFile, Chr(34), "")
  47.  
  48. Set objFSO = CreateObject("Scripting.FileSystemObject")
  49. set objFilename = objFSO.GetFile(strNewFile)
  50.  
  51. strNewFileExt = objFSO.GetExtensionName(objFilename)
  52.  
  53. if debug > 0 Then
  54. Wscript.echo "Debug: New File Detected - " & objFilename
  55. Wscript.echo ""
  56. end if
  57.  
  58. if strNewFileExt = "txt" Then
  59. strNewRecFile = objFSO.GetParentFolderName(objFilename) & "\" & objFSO.GetBaseName(objFilename) & ".ts"
  60. strNewRecFileName = objFSO.GetBaseName(objFilename) & ".ts"
  61. if objFSO.FileExists(strNewRecFile) then
  62. Wscript.echo "Recording Finished: " & strNewRecFileName
  63. Wscript.echo "Stripping 1SEG/SD..."
  64.  
  65. Set objShell = CreateObject("Wscript.Shell")
  66. if debug > 0 Then
  67. Wscript.echo "Debug: " & strTsplit & """" & strNewRecFile & """"
  68. ret = objshell.run (strTsplit & """" & strNewRecFile & """")
  69. else
  70. ret = objshell.run (strTsplit & """" & strNewRecFile & """")
  71. end if
  72.  
  73. Wscript.sleep(60000)
  74.  
  75. end if
  76. elseif strNewFileExt = "ts" Then
  77. if InStr(objFSO.GetBaseName(objFilename), "_HD") = 0 Then
  78. Wscript.echo "New Recording Started: " & objFSO.GetBaseName(objFilename) & "." & objFSO.GetExtensionName(objFilename)
  79. end if
  80. end if
  81.  
  82. Loop
Add Comment
Please, Sign In to add comment