brave-backup/brave_set_assets.py
2025-10-19 00:58:37 +02:00

43 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import shutil
def copy_tree(src_dir, dst_dir):
"""Recursively copy all files and folders from src_dir to dst_dir."""
for root, dirs, files in os.walk(src_dir):
rel_path = os.path.relpath(root, src_dir)
dest_root = os.path.join(dst_dir, rel_path) if rel_path != "." else dst_dir
os.makedirs(dest_root, exist_ok=True)
for file in files:
src_file = os.path.join(root, file)
dst_file = os.path.join(dest_root, file)
shutil.copy2(src_file, dst_file)
print(f"✔ Copied: {src_file}{dst_file}")
def main():
# Source directory (next to this script)
script_dir = os.path.dirname(os.path.abspath(__file__))
assets_dir = os.path.join(script_dir, "assets")
# Fallback to _assets if assets/ doesn't exist
if not os.path.exists(assets_dir):
alt_assets_dir = os.path.join(script_dir, "_assets")
if os.path.exists(alt_assets_dir):
print(f"⚠️ 'assets' not found, using '_assets' instead.")
assets_dir = alt_assets_dir
else:
print(f"❌ Neither 'assets' nor '_assets' directory found in {script_dir}")
return
# Destination (Brave profile folder)
base_dir = os.path.expanduser("~/Library/Application Support/BraveSoftware/Brave-Browser")
# Copy everything from assets → Brave-Browser
copy_tree(assets_dir, base_dir)
print("\n✅ Brave configuration copied successfully.")
if __name__ == "__main__":
main()