code: def dir2fn(ofn, ifn, suffix) -> Union[None, Path]:
      
      if not ofn:  # no output file desired
          return None
  
      ofn = Path(ofn).expanduser()
      ifn = Path(ifn).expanduser()
      assert ifn.is_file()
  
      if ofn.suffix == suffix:  # must already be a filename
          pass
      else:  # must be a directory
          assert ofn.is_dir(), f'create directory {ofn}'
          ofn = ofn / ifn.with_suffix(suffix).name
  
      try:
          assert not ofn.samefile(ifn), f'do not overwrite input file! {ifn}'
      except FileNotFoundError:  # a good thing, the output file doesn't exist and hence it's not the input file
          pass
  
      return ofn
docs: ofn = filename or output directory, to create filename based on ifn
      ifn = input filename (don't overwrite!)
      suffix = desired file extension e.g. .h5