Files
novafarma/scripts/flatten_adhd_structure.py

113 lines
2.9 KiB
Python
Executable File

#!/usr/bin/env python3
"""
ADHD-FRIENDLY FOLDER FLATTENING
Poenostavi vse mape - NO SUBFOLDERS!
"""
import os
import shutil
from pathlib import Path
# Base paths
BASE = Path("/Users/davidkotnik/repos/novafarma/assets/slike")
print("🎯 ADHD-FRIENDLY STRUKTURA - Flattening...")
print("=" * 60)
# Step 1: Flatten all biome folders
def flatten_biome(biome_path):
"""Premakne vse datoteke iz podmap v glavno mapo"""
if not biome_path.exists():
return
print(f"\n📁 Flattening: {biome_path.name}")
# Find all subfolders
subfolders = [d for d in biome_path.iterdir() if d.is_dir()]
if not subfolders:
print(f" ✅ Already flat!")
return
moved = 0
for subfolder in subfolders:
# Move all files from subfolder to parent
for file in subfolder.rglob("*"):
if file.is_file():
# Create new name with subfolder prefix
new_name = f"{subfolder.name}_{file.name}"
new_path = biome_path / new_name
# Avoid overwriting
if new_path.exists():
counter = 1
stem = new_path.stem
suffix = new_path.suffix
while new_path.exists():
new_path = biome_path / f"{stem}_{counter}{suffix}"
counter += 1
try:
shutil.move(str(file), str(new_path))
moved += 1
except Exception as e:
print(f" ⚠️ Error moving {file.name}: {e}")
# Remove empty subfolder
try:
shutil.rmtree(subfolder)
print(f" 🗑️ Removed: {subfolder.name}/")
except:
pass
print(f" ✅ Moved {moved} files, flattened!")
# Biomes to flatten
biomes = [
"01_dolina_farm",
"02_dark_forest",
"02_temni_gozd",
"03_abandoned_town",
"03_zapusceno_mesto",
"04_river_valley",
"05_mountain_pass",
"06_swamp",
"07_desert",
"08_snow_zone",
"09_underground",
"10_magical_grove",
"11_ancient_ruins",
"12_coastal_area",
"13_volcano",
"14_crystal_caves",
"15_floating_islands",
"16_corrupted_lands",
"17_spirit_realm",
"18_final_zone",
]
for biome in biomes:
biome_path = BASE / biome
flatten_biome(biome_path)
# Step 2: Flatten other categories
print("\n" + "=" * 60)
print("📦 Flattening other categories...")
other_categories = [
"liki",
"sovrazniki",
"zgradbe",
"rastline",
"orozje",
"cutscenes",
]
for category in other_categories:
cat_path = BASE / category
flatten_biome(cat_path)
print("\n" + "=" * 60)
print("✅ DONE! Vse mape so zdaj FLAT (ADHD-friendly)!")
print("\nVse slike so zdaj direktno v glavnih mapah - NO SUBFOLDERS!")