INNER CODE UNIT · Python

copy_tmp_to_source

changyeyu/LLM-RL-Visualized · src/clip_images.py:48

def copy_tmp_to_source(input_dir, tmp_dir):
    """
    Copies files from tmp_dir back to input_dir (overwriting original files).
    """
    for root, dirs, files in os.walk(tmp_dir):
        for file in files:
            tmp_file = os.path.join(root, file)
            # Compute the relative path from tmp_dir
            rel_path = os.path.relpath(tmp_file, tmp_dir)
            original_file = os.path.join(input_dir, rel_path)
            
            # Ensure the original directory exists (for safety)
            os.makedirs(os.path.dirname(original_file), exist_ok=True)
            print(f"Overwriting {original_file} with {tmp_file}")
            shutil.copy2(tmp_file, original_file)

if __name__ == "__main__":
    # List of directories to process

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…