+++ /dev/null
-#!/bin/bash
-
-# inputdesc specification:
-#
-# general options
-# output_file\tinput_file\tspecific_options
-# output_file\tinput_file\tspecific_options
-#
-# Example inputdesc
-# --filters pp=ci,crop=704:576:10:0,scale=768:576,denoise3d,harddup
-# 1x01.avi dvd://1 --dvd DISC1
-# 1x02.avi dvd://1 --dvd DISC2
-
-
-encoder="$1"
-input="$2"
-if [ -z "$input" ]; then
- echo "Usage: $0 toh264.py inputdesc"
- exit 1
-fi
-
-# Read the general options
-options="$(head -n 1 "$input")"
-
-# Read each file description
-tail -n +2 "$input" | while read line; do
- out=$(echo "$line" | cut -d ' ' -f 1)
- in=$(echo "$line" | cut -d ' ' -f 2)
- specopts=$(echo "$line" | cut -d ' ' -f 3)
- nice -n 10 "$encoder" $options $specopts "$in" "$out"
-done
-
--- /dev/null
+#!/usr/bin/env python
+
+import optparse, shlex, subprocess, sys
+
+def parseArgs():
+ parser = optparse.OptionParser(usage="%prog batchfile1 [batchfile2] ...")
+ opts, args = parser.parse_args(sys.argv[1:])
+ return args
+
+def run(args):
+ subprocess.Popen(args).wait()
+
+def batchProcess(fd):
+ opts = [[], []]
+ for line in fd:
+ args = shlex.split(line)
+ if line.startswith("\t\t"):
+ run(opts[0] + opts[1] + args)
+ elif line.startswith("\t"):
+ opts[1] = args
+ else:
+ opts[0] = args
+
+def main():
+ args = parseArgs()
+ for name in args:
+ batchProcess(open(name))
+
+if __name__ == "__main__":
+ main()
+