(old_dir, new_dir)
Migrate a directory to a new location
Migrate a directory to a new location
Migrate a directory to a new location
def migrate_directory(old_dir, new_dir):
    """Migrate a directory to a new location"""
    if not os.path.exists(old_dir):
        return
    if os.path.exists(new_dir):
        # both dirs exist
        for f in os.listdir(old_dir):
            src = os.path.join(old_dir, f)
            dest = os.path.join(new_dir, f)
            if os.path.isdir(src):
                migrate_directory(src, dest)
            else:
                migrate_file(src, dest)
    else:
        logger.warning(f"Moving directory to new location {old_dir} -> {new_dir}")
        shutil.move(old_dir, new_dir)
def migrate_directory ( old_dir , new_dir ) : if not os . path . exists ( old_dir ) : return if os . path . exists ( new_dir ) : # both dirs exist for f in os . listdir ( old_dir ) : src = os . path . join ( old_dir , f ) dest = os . path . join ( new_dir , f ) if os . path . isdir ( src ) : migrate_directory ( src , dest ) else : migrate_file ( src , dest ) else : logger . warning ( f"Moving directory to new location {old_dir} -> {new_dir}" ) shutil . move ( old_dir , new_dir )