@@ -696,22 +696,36 @@ def __call__(self, parser, namespace, values, option_string=None):
696
696
def output_filename (input_filename ):
697
697
if args .outputfile_pattern is None :
698
698
return input_filename
699
+
699
700
input_path = Path (input_filename )
700
- return f"{ args .outputfile_pattern } {{suffix}}" .format (input_path .stem , suffix = input_path .suffix )
701
+ output_path = Path (args .outputfile_pattern
702
+ .replace ("%n" , input_path .stem )
703
+ .replace ("%p" , str (input_path .parent .resolve ()))
704
+ .replace ("%%" , "%" )).with_suffix (input_path .suffix )
705
+
706
+ return str (output_path )
701
707
702
708
703
709
if __name__ == '__main__' :
704
710
705
711
parser = argparse .ArgumentParser (
706
712
description = 'Manipulate Secondlife .anim files' ,
707
- fromfile_prefix_chars = '@' )
713
+ fromfile_prefix_chars = '@' , formatter_class = argparse .RawDescriptionHelpFormatter ,
714
+ epilog = """
715
+ output file pattern flags:
716
+ %n: input file name
717
+ %p: input file directory
718
+ %%: literal '%'
719
+ file extensions will be appended automatically
720
+ """ )
721
+
708
722
parser .add_argument ('files' , nargs = '+' , help = 'anim files to dump or process' )
709
723
parser .add_argument ('--verbose' , '-v' , action = 'count' , default = 0 )
710
724
parser .add_argument ('--no-sort' , '-U' , action = 'store_false' , dest = 'sort' ,
711
725
help = "when printing joints with -v, show in file order rather than abc order" )
712
726
parser .add_argument ('--markdown' , '--md' , action = 'store_true' , help = "output in markdown table" )
713
- parser .add_argument ('--outputfile-pattern' , '-o' )
714
-
727
+ parser .add_argument ('--outputfile-pattern' , '-o' ,
728
+ help = 'Output anim file path/name, see \' output file pattern flags \' below for details' )
715
729
parser .add_argument ('--time-scale' , '--tscale' , '--speed' , '-s' , action = AppendObjectAction ,
716
730
dest = 'actions' , func = SpeedAnimation , nargs = 1 , type = float ,
717
731
help = "Adjust duration by the given factor eg 2.0 for half-speed/double duration, or 0.5 for double speed/half duration" )
0 commit comments