addmag.py 760 B

123456789101112131415161718192021222324
  1. import os
  2. import shutil
  3. def ensure_mag_0_exists(root_dir):
  4. for current_dir, subdirs, files in os.walk(root_dir):
  5. # Skip if mag-0.png already exists
  6. if "mag-0.png" in files:
  7. continue
  8. parent_dir = os.path.dirname(current_dir)
  9. source_path = os.path.join(parent_dir, "mag-0.png")
  10. target_path = os.path.join(current_dir, "mag-0.png")
  11. if os.path.isfile(source_path):
  12. print(f"Copying {source_path} → {target_path}")
  13. shutil.copyfile(source_path, target_path)
  14. else:
  15. print(f"No mag-0.png found to copy for: {current_dir}")
  16. # Change this to your actual root folder
  17. root_folder = os.path.abspath(os.path.dirname(__file__))
  18. ensure_mag_0_exists(root_folder)