Blue_MiSfit
3rd April 2008, 21:09
Hey folks,
So I'm trying to automate some batch processing - and I'm hoping you can help me out!
My objective is this:
1) Iterate through a directory tree (specifying a top level)
2) For all D2V files encountered, create an avisynth script with a simple MPEG2Source(...). I will add some filters to these scripts later.
I have copied here an example script that does something similar. This is ripped straight out of the avsP Macro manual. I'm just new to Python and have a little trouble wrapping my head around all this.
I think I can figure most of it out, but I'm not sure how to specify creating an AviSynth script for only d2v files, as this script apparently creates a script for _all_ files.
import os
# Get the directory containing source files
dirname = avsp.GetDirectory()
if dirname:
# Generate each of the avisynth scripts
for filename in os.listdir(dirname):
fullname = os.path.join(dirname, filename)
if os.path.isfile(fullname):
# Get the extension-based template string
srctxt = avsp.GetSourceString(fullname)
# Create the script string
scripttxt = srctxt + '\n' + 'Sharpen(1.0)\nInfo()'
# Write the script text to a file
f = open(fullname + '.avs', 'w')
f.write(scripttxt)
f.close()
This script creates an AVS for each file, attempts to auto-detect the file type, and assign the appropriate source filter (very cool), then puts
Sharpen(1.0)
Info()
in the body of each script. It's a start!
Your help is appreciated!
~MiSfit
So I'm trying to automate some batch processing - and I'm hoping you can help me out!
My objective is this:
1) Iterate through a directory tree (specifying a top level)
2) For all D2V files encountered, create an avisynth script with a simple MPEG2Source(...). I will add some filters to these scripts later.
I have copied here an example script that does something similar. This is ripped straight out of the avsP Macro manual. I'm just new to Python and have a little trouble wrapping my head around all this.
I think I can figure most of it out, but I'm not sure how to specify creating an AviSynth script for only d2v files, as this script apparently creates a script for _all_ files.
import os
# Get the directory containing source files
dirname = avsp.GetDirectory()
if dirname:
# Generate each of the avisynth scripts
for filename in os.listdir(dirname):
fullname = os.path.join(dirname, filename)
if os.path.isfile(fullname):
# Get the extension-based template string
srctxt = avsp.GetSourceString(fullname)
# Create the script string
scripttxt = srctxt + '\n' + 'Sharpen(1.0)\nInfo()'
# Write the script text to a file
f = open(fullname + '.avs', 'w')
f.write(scripttxt)
f.close()
This script creates an AVS for each file, attempts to auto-detect the file type, and assign the appropriate source filter (very cool), then puts
Sharpen(1.0)
Info()
in the body of each script. It's a start!
Your help is appreciated!
~MiSfit