SESSION COMPLETE - Deep Analysis and Organization Done
This commit is contained in:
112
scripts/flatten_adhd_structure.py
Executable file
112
scripts/flatten_adhd_structure.py
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/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!")
|
||||
126
scripts/organize_assets_simple.py
Normal file
126
scripts/organize_assets_simple.py
Normal file
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
SUPER SIMPLE ASSET ORGANIZER
|
||||
Organizira vse slike v pravilne mape - BREZ podmap!
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
BASE = Path("/Users/davidkotnik/repos/novafarma/assets/slike")
|
||||
|
||||
# Asset classification rules (by filename patterns)
|
||||
CLASSIFICATION = {
|
||||
"kai": ["kai_", "kai"],
|
||||
"ana": ["ana_", "ana"],
|
||||
"gronk": ["gronk", "grok_", "grok"],
|
||||
"npcs": ["npc_", "trader", "blacksmith", "healer", "farmer", "elder", "cook"],
|
||||
"liki": ["character_", "survivor"],
|
||||
|
||||
"sovrazniki": ["zombie", "skeleton", "ghost", "mummy", "mutant", "boss", "enemy", "monster"],
|
||||
|
||||
"zgradbe": ["building_", "house_", "barn_", "tower_", "wall_", "fence_", "gate_"],
|
||||
|
||||
"rastline": ["plant_", "bush_", "flower_", "grass_", "crop_", "wheat_", "corn_", "tomato_", "carrot_"],
|
||||
"drevesa": ["tree_", "oak", "pine", "dead_tree"],
|
||||
"semena": ["seed_", "seeds_"],
|
||||
|
||||
"orozje": ["weapon_"],
|
||||
"hladno": ["sword", "axe", "mec_", "sekira_", "melee_"],
|
||||
"strelno": ["bow", "arrow", "gun", "lok_", "pistol", "rifle"],
|
||||
|
||||
"orodja": ["tool_", "hoe", "pickaxe", "watering", "shovel", "motika"],
|
||||
|
||||
"hrana": ["food_", "bread_", "meat_", "fish_", "cheese_", "apple_"],
|
||||
"predmeti": ["item_", "potion_", "coin_", "gem_", "key_"],
|
||||
|
||||
"ui": ["ui_", "button_", "icon_", "cursor_", "menu_", "bar_", "heart_", "star_"],
|
||||
|
||||
"voda": ["water_", "ocean_", "river_", "lake_"],
|
||||
|
||||
"efekti": ["effect_", "smoke_", "fire_", "magic_", "explosion_", "sparkle_"],
|
||||
"dim": ["smoke_"],
|
||||
|
||||
"cutscene": ["cutscene_"],
|
||||
"cutscenes": ["scene_"],
|
||||
|
||||
# Catch-all
|
||||
"ostalo": [], # Everything else goes here
|
||||
}
|
||||
|
||||
print("🎯 ORGANIZING ASSETS...")
|
||||
print("=" * 70)
|
||||
|
||||
# Get all PNG files
|
||||
all_pngs = list(BASE.rglob("*.png"))
|
||||
print(f"📊 Found {len(all_pngs)} PNG files")
|
||||
|
||||
# Stats
|
||||
moved = 0
|
||||
skipped = 0
|
||||
errors = 0
|
||||
|
||||
for png_file in all_pngs:
|
||||
# Skip if already in correct top-level folder
|
||||
parent_name = png_file.parent.name
|
||||
if parent_name in CLASSIFICATION.keys():
|
||||
# Check if filename matches parent
|
||||
filename_lower = png_file.name.lower()
|
||||
patterns = CLASSIFICATION.get(parent_name, [])
|
||||
|
||||
# If parent is "ostalo", skip (catch-all)
|
||||
if parent_name == "ostalo":
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
# Check if file matches this category
|
||||
matches = any(pattern in filename_lower for pattern in patterns)
|
||||
if matches or not patterns: # If no patterns (UI, etc) or matches
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
# Classify file
|
||||
filename_lower = png_file.name.lower()
|
||||
target_folder = "ostalo" # Default
|
||||
|
||||
for folder, patterns in CLASSIFICATION.items():
|
||||
if folder == "ostalo":
|
||||
continue
|
||||
for pattern in patterns:
|
||||
if pattern in filename_lower:
|
||||
target_folder = folder
|
||||
break
|
||||
if target_folder != "ostalo":
|
||||
break
|
||||
|
||||
# Create target folder if needed
|
||||
target_path = BASE / target_folder
|
||||
target_path.mkdir(exist_ok=True)
|
||||
|
||||
# Move file
|
||||
dest = target_path / png_file.name
|
||||
|
||||
# Handle duplicates
|
||||
if dest.exists():
|
||||
counter = 1
|
||||
stem = dest.stem
|
||||
suffix = dest.suffix
|
||||
while dest.exists():
|
||||
dest = target_path / f"{stem}_{counter}{suffix}"
|
||||
counter += 1
|
||||
|
||||
try:
|
||||
shutil.move(str(png_file), str(dest))
|
||||
moved += 1
|
||||
print(f"✅ Moved: {png_file.name} → {target_folder}/")
|
||||
except Exception as e:
|
||||
errors += 1
|
||||
print(f"❌ Error moving {png_file.name}: {e}")
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print(f"✅ DONE!")
|
||||
print(f"📦 Moved: {moved} files")
|
||||
print(f"⏭️ Skipped: {skipped} files (already in correct location)")
|
||||
print(f"❌ Errors: {errors} files")
|
||||
print("\nVse slike so zdaj organizirane v pravilne mape!")
|
||||
Reference in New Issue
Block a user