Created
March 13, 2013 16:25
-
-
Save mikeboers/5153786 to your computer and use it in GitHub Desktop.
Wrapper around partio's `partconv` tool for handling Maya file naming conventions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from subprocess import call | |
import os | |
import sys | |
import re | |
if len(sys.argv) < 3: | |
print 'usage: %s particle_folder output_type+' % sys.argv[0] | |
exit(1) | |
src_dir = sys.argv[1].rstrip('/') | |
for format_ in sys.argv[2:]: | |
dst_dir = src_dir + '_' + format_.upper() | |
if not os.path.exists(dst_dir): | |
os.makedirs(dst_dir) | |
for src_name in os.listdir(src_dir): | |
if src_name.startswith('.'): | |
continue | |
m = re.match(r'^(.+)\.(\d+)\.(.+)$', src_name) | |
if not m: | |
continue | |
base, frame, _ = m.groups() | |
dst_name = '%s.%s.%s' % (base, 250 * int(frame), format_.lower()) | |
print dst_name | |
call(['partconv', os.path.join(src_dir, src_name), os.path.join(dst_dir, dst_name)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment