Object mediaFile = MediaFileAPI.GetMediaFileForID(SJQ4_METADATA.get("SJQ4_ID").toInteger()) String channel = AiringAPI.GetAiringChannelName(mediaFile) /* Building the file name from the SJQ env vars is fine, but you already have the media file object so you might find it easier/more reliable to use the MediaFileAPI functions to extract the file name. But then again, if this is working for you then that's fine. */ String file = SJQ4_METADATA.get("SJQ4_PATH") + SJQ4_METADATA.get("SJQ4_LAST_SEGMENT") String fileType = SJQ4_METADATA.get("SJQ4_LAST_SEGMENT_TYPE") if(channel ==~ /wanedt/) { println "Running CBSSKIP" println file def command = ['C:/comskip/comskip.exe', '--ini=C:/comskip/comskip-cbs.ini', file].execute() consumeProcessOutput(System.stdout, System.stderr) command.waitFor() if (command.exitValue()) return 1 else return 0 } else if(channel ==~ /wptadt/) { println "Running ABCSKIP" println file def command = ['C:/comskip/comskip.exe', '--ini=C:/comskip/comskip-abc.ini', file].execute() consumeProcessOutput(System.stdout, System.stderr) command.waitFor() if (command.exitValue()) return 1 else return 0 } else if(channel ==~ /wisedt/) { println "Running NBCSKIP" println file def command = ['C:/comskip/comskip.exe', '--ini=C:/comskip/comskip-nbc.ini', file].execute() consumeProcessOutput(System.stdout, System.stderr) command.waitFor() if (command.exitValue()) return 1 else return 0 } else if(channel ==~ /foxdt/) { println "Running FOXSKIP" println file def command = ['C:/comskip/comskip.exe', '--ini=C:/comskip/comskip-Fox.ini', file].execute() consumeProcessOutput(System.stdout, System.stderr) command.waitFor() if (command.exitValue()) return 1 else return 0 } else if(channel !=~ /WANEDT|WPTADT|WISEDT|FOXDT|HBO.*|ACMAXHD|5MAXHD|HDNETMV|MAX.*|MOMAX|STZ.*|ENC.*|SHO.*|TMC.*|PPV.*/) { println "Running OTHER (Default)" println file def command = ['C:/comskip/comskip.exe', '--ini=C:/comskip/comskip-OTHER.ini', file].execute() consumeProcessOutput(System.stdout, System.stderr) command.waitFor() if (command.exitValue()) return 1 else return 0 } else { println 'Not running comskip for this recording!' return 0 }