convert_pbrt-v4.py 912 B

1234567891011121314151617181920212223242526272829
  1. import os
  2. import subprocess
  3. from pathlib import Path
  4. import argparse
  5. parser = argparse.ArgumentParser(description="Convert pbrt 4 files of folder into another one")
  6. parser.add_argument('--previous', type=str, help='previous pbrt folder', required=True)
  7. parser.add_argument('--new', type=str, help='new pbrt folder (with all copy)', required=True)
  8. parser.add_argument('--pbrt', type=str, help='pbrt executable', required=True)
  9. args = parser.parse_args()
  10. p_previous = args.previous
  11. p_new = args.new
  12. p_pbrt = args.pbrt
  13. command = p_pbrt + " --upgrade {0} > {1}"
  14. os.system('cp -r {0} {1}'.format(p_previous, p_new))
  15. for path in Path(p_previous).rglob('*.pbrt'):
  16. elements = str(path).split('/')
  17. head = elements[0]
  18. del elements[0]
  19. print(path, '=>', p_new)
  20. str_command = command.format(path, os.path.join(p_new, os.path.split(path)[-1]))
  21. subprocess.call(str_command, shell=True)