Skip to content

Instantly share code, notes, and snippets.

@mikeboers
Created March 13, 2013 16:25
Show Gist options
  • Save mikeboers/5153786 to your computer and use it in GitHub Desktop.
Save mikeboers/5153786 to your computer and use it in GitHub Desktop.
Wrapper around partio's `partconv` tool for handling Maya file naming conventions.
#!/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