Files
openwrt/docs/agent-notes/reorganize_openwrt.py
2026-03-22 00:54:57 -07:00

54 lines
1.3 KiB
Python
Executable File

import os
import shutil
BASE_DIR = "/home/user/Public/Projects/OpenWRT"
STRUCTURE = {
"sdk": [
"openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64"
],
"sources": [
"btop"
],
"packages": [
"btop-flint2-package",
"btop-openwrt-package"
],
"bin": [
"btop-flint2"
]
}
def reorganize():
print(f"Reorganizing {BASE_DIR}...")
# Create new directories
for folder in STRUCTURE.keys():
path = os.path.join(BASE_DIR, folder)
if not os.path.exists(path):
print(f"Creating directory: {path}")
os.makedirs(path)
else:
print(f"Directory exists: {path}")
# Move items
for folder, items in STRUCTURE.items():
dest_dir = os.path.join(BASE_DIR, folder)
for item in items:
src_path = os.path.join(BASE_DIR, item)
dest_path = os.path.join(dest_dir, item)
if os.path.exists(src_path):
print(f"Moving {item} to {folder}/...")
try:
shutil.move(src_path, dest_path)
except Exception as e:
print(f"Error moving {item}: {e}")
else:
print(f"Warning: Source not found: {item}")
print("Reorganization complete.")
if __name__ == "__main__":
reorganize()