def move_to_parent_folder(workdir):
 workdir = os.path.abspath(os.path.normpath(workdir))
 dest = os.path.abspath(os.path.normpath(os.path.join(workdir, '..')))
 for item in os.listdir(workdir):
  if (item.lower() in ('video_ts', 'audio_ts', 'bdmv')):
   return (workdir, True)
 for (root, dirs, files) in os.walk(workdir):
  for _file in files:
   path = os.path.join(root, _file)
   new_path = path.replace(workdir, dest)
   (ok, new_path) = move_to_path(path, new_path)
   if (not ok):
    return (dest, False)
 cleanup_empty_directories(workdir)
 return (dest, True)

def move_to_parent_folder ( workdir ) : workdir = os . path . abspath ( os . path . normpath ( workdir ) ) dest = os . path . abspath ( os . path . normpath ( os . path . join ( workdir , '..' ) ) ) for item in os . listdir ( workdir ) : if ( item . lower ( ) in ( 'video_ts' , 'audio_ts' , 'bdmv' ) ) : return ( workdir , True ) for ( root , dirs , files ) in os . walk ( workdir ) : for _file in files : path = os . path . join ( root , _file ) new_path = path . replace ( workdir , dest ) ( ok , new_path ) = move_to_path ( path , new_path ) if ( not ok ) : return ( dest , False ) cleanup_empty_directories ( workdir ) return ( dest , True )
move all in workdir into workdir/ .