code: def _output_type_by_input_path(inpaths, itype, fmsg):
      
      msg = ("Specify inpath and/or outpath type[s] with -I/--itype "
             "or -O/--otype option explicitly")
      if itype is None:
          try:
              otype = API.find(inpaths[0]).type()
          except API.UnknownFileTypeError:
              _exit_with_output((fmsg % inpaths[0]) + msg, 1)
          except (ValueError, IndexError):
              _exit_with_output(msg, 1)
      else:
          otype = itype
  
      return otype
docs: :param inpaths: List of input file paths
      :param itype: Input type or None
      :param fmsg: message if it cannot detect otype by 'inpath'
      :return: Output type :: str