Hi folks! This is my first python script! It will be executed within AvsP, which is an application for writing AviSynth scripts. It provides a full Python interface, for macros and other operations.
Here's the code I have now:
# batchCreateD2Vs
# by Derek Prestegard
# Last Modified 4/3/08
#
# This python script works through a directory, and generates a d2v for all
# VOB and MPG files encountered. It will not extract audio, and it will
# honor pullown flags
# Changelog:
# r001 4/3/08 - 4:47 PM - Initial script
import os
import fnmatch
# Get the directory containing source files
dirname = avsp.GetDirectory()
# Create a BAT file
f= open('batchDecode.bat', 'w')
if dirname:
# Generate each of the d2v files
for filename in os.listdir(dirname):
fullname = os.path.join(dirname, filename)
if os.path.isfile(fullname):
# Only work on VOBs and MPGs (for now)
if fnmatch.fnmatch(filename, '*.vob'):
# Build the DGIndex command string
indexStr = 'dgindex.exe -IF=[' + fullname + '] -FO=0 -OM=0 -OF=[' + fullname + '] -MINIMIZE -EXIT \n'
# Write the string to a BAT file
f.write(indexStr)
if fnmatch.fnmatch(filename, '*.mpg'):
# Build the DGIndex command string
indexStr = 'dgindex.exe -IF=[' + fullname + '] -FO=0 -OM=0 -OF=[' + fullname + '] -MINIMIZE -EXIT \n'
# Write the string to a BAT file
f.write(indexStr)
f.close()
I know, its ugly :) I'm no programmer. It's complaining about line 26, which is:
if fnmatch.fnmatch(filename, '*.vob'):
From my understanding, this line should evaluate whether "filename" ends in .vob.
I want my script to operate on VOBs and MPGs, so if I can combine that into a single IF statement, that would be ideal.
I welcome your input!
Thanks,
~MiSfit