def aggregate_filename(files, new_suffix):
 path = os.path.split(files[0])[0]
 names = [os.path.splitext(os.path.split(x)[1])[0] for x in files]
 common_prefix = os.path.commonprefix(names)
 path = os.getcwd()
 if (common_prefix == u''):
  return os.path.abspath(os.path.join(path, (((os.path.splitext(files[0])[0] + u'_') + new_suffix) + u'.mnc')))
 else:
  return os.path.abspath(os.path.join(path, (((common_prefix + u'_') + new_suffix) + u'.mnc')))

def aggregate_filename ( files , new_suffix ) : path = os . path . split ( files [ 0 ] ) [ 0 ] names = [ os . path . splitext ( os . path . split ( x ) [ 1 ] ) [ 0 ] for x in files ] common_prefix = os . path . commonprefix ( names ) path = os . getcwd ( ) if ( common_prefix == u'' ) : return os . path . abspath ( os . path . join ( path , ( ( ( os . path . splitext ( files [ 0 ] ) [ 0 ] + u'_' ) + new_suffix ) + u'.mnc' ) ) ) else : return os . path . abspath ( os . path . join ( path , ( ( ( common_prefix + u'_' ) + new_suffix ) + u'.mnc' ) ) )
try to work out a sensible name given a set of files that have been combined in some way .