def rename_and_collapse_folder(oldpath, newpath, files):
 orgpath = oldpath
 items = globber(oldpath)
 if (len(items) == 1):
  folder = items[0]
  folder_path = os.path.join(oldpath, folder)
  if (os.path.isdir(folder_path) and (folder not in ('VIDEO_TS', 'AUDIO_TS'))):
   logging.info('Collapsing %s', os.path.join(newpath, folder))
   oldpath = folder_path
 oldpath = os.path.normpath(oldpath)
 newpath = os.path.normpath(newpath)
 files = [os.path.normpath(f).replace(oldpath, newpath) for f in files]
 renamer(oldpath, newpath)
 try:
  remove_dir(orgpath)
 except:
  pass
 return files

def rename_and_collapse_folder ( oldpath , newpath , files ) : orgpath = oldpath items = globber ( oldpath ) if ( len ( items ) == 1 ) : folder = items [ 0 ] folder_path = os . path . join ( oldpath , folder ) if ( os . path . isdir ( folder_path ) and ( folder not in ( 'VIDEO_TS' , 'AUDIO_TS' ) ) ) : logging . info ( 'Collapsing %s' , os . path . join ( newpath , folder ) ) oldpath = folder_path oldpath = os . path . normpath ( oldpath ) newpath = os . path . normpath ( newpath ) files = [ os . path . normpath ( f ) . replace ( oldpath , newpath ) for f in files ] renamer ( oldpath , newpath ) try : remove_dir ( orgpath ) except : pass return files
rename folder .