Ok this was a fairly interesting stat collection so i whiped up a python script to do this. I should invest some more time in lexing the right thing (now i lex lines but I should lex combination of lines split by ; instead), second thing is should allow for long strings too but hey its a hack. CHANGE the pathname!
"""renderRangeFormAllMA.py 0.1
Authors: Janne 'Joojaa' Ojala
Testing: not much testing, ran a few times on my
entire local project list. Some problems but
no critical issues.
License: Creative Commons, Attribution, Share Alike
Request: visualize686
About:
A simple script that will recursively iterate over
your folders and find all maya ascii files. Then try
to decipher the render range and calculate number of
frames, and tally this up.
Install Instructions:
place this text in a file named:
renderRangeFormAllMA.py
change the pathname and execute.
Usage:
change the pathname to point to your root
Changelist:
27.11.2010 - Original file
"""
import sys, os, fnmatch, shlex, time
#folder name to start searching maya ascii files from
pathname = r'C:\Some\folder'
def find_files(directory, pattern):
for root, dirs, files in os.walk(directory):
if "incrementalSave" in dirs: #skip incremental saves
dirs.remove("incrementalSave")
for basename in files:
if fnmatch.fnmatch(basename, pattern):
filename = os.path.join(root, basename)
yield filename
# extend to understand maya boolean vocabulary
yes = True
no = False
totalFrames = 0
nFiles = 0
oddFailures = 0
sys.stdout.write("processing please wait")
sys.stdout.write(".")
start = time.clock()
for filename in find_files(pathname, '*.ma'):
fp = open(filename)
name = os.path.basename(filename)
# make a aonymous object for populating attributes
obj = lambda: None
obj.an = False
try:
while True:
line = fp.next()
if line.startswith("select -ne :defaultRenderGlobals;"):
line = fp.next()
break
while line.startswith('\t'):
attr = shlex.split(line)[1]
attr = attr[1:]
try:
value = eval(shlex.split(line)[-1].strip(';'))
except:
value = shlex.split(line)[-1].strip(';')
setattr(obj,attr,value)
line = fp.next()
if obj.an:
try:
totalFrames += int(obj.ef) - int(obj.fs) + 1
except:
oddFailures += 1
else:
totalFrames += 1
except StopIteration:
totalFrames += 1 # has no globals ok then it has one frame
except:
print fp.name, line, fp.next()
raise
nFiles += 1
if time.clock() - start > 2:
start = time.clock()
sys.stdout.write(".")
fp.close()
sys.stdout.write("\n")
print totalFrames, "frames in", nFiles, "maya ascii files and", oddFailures, "unparsed files"
PS: this script has a security issue so dont run this on a webserver! 