import os import sys import argparse def main(input_path, output_path): num = len(input_path) + 1 for root, dirs, files in os.walk(input_path): for file in files: if os.path.splitext(file)[-1] in ['.osg']: if not os.path.exists(os.path.join(output_path, root[num:])): os.makedirs(os.path.join(output_path, root[num:])) cmd = r'./OpenSceneGraph-3.6.5-VC2019-64-Release/bin/osgconv.exe/osgconv.exe {osg_input_path} {osg_output_path}'.format( osg_input_path=os.path.join(root, file), osg_output_path=os.path.join(output_path, root[num:], file.replace('osg', 'obj'))) print(cmd) os.system(cmd) if __name__ == '__main__': # if len(sys.argv) == 1: # print(""" # 功能:osg转obj # usge:python dds_to_png.py -i input_path -o output_path # eg: python 4s_script_20220311.py -i /data/slice/data/inputpath -o /data/slice/data/inputpath # -i --input_path osg输入目录 # -o --output_path obj输出目录 # """) # # args = argparse.ArgumentParser() # args.add_argument('-i', '--input_path', required=True, type=str, help='osg输入目录') # args.add_argument('-o', '--output_path', required=True, type=str, help='obj输出目录') # # # 参数获取 # parse = args.parse_args() # input_path = parse.input_path # output_path = parse.output_path input_path = r'D:\ty_data\漪汾桥-迎泽桥XML' output_path = r'D:\输出' main(input_path, output_path)