#!/usr/bin/env python3 """ 🗂️ ORGANIZE ENVIRONMENT & ANIMAL ASSETS Move images from old folders to new organized structure """ import os import shutil from pathlib import Path # Base directory BASE_DIR = Path("/Users/davidkotnik/repos/novafarma/assets/slike") # Source folders OLD_ANIMALS = BASE_DIR / "zivali" OLD_ENVIRONMENT = BASE_DIR / "okolje" OLD_TERRAIN = BASE_DIR / "teren" OLD_DECORATIONS = BASE_DIR / "dekoracije" # Destination folders ANIMALS_DIR = BASE_DIR / "animals" ENV_DIR = BASE_DIR / "environment" # Animal categorization patterns ANIMAL_PATTERNS = { "domestic": [ "cow", "chicken", "sheep", "pig", "horse", "goat", "duck", "rabbit", "cat", "dog", "krava", "kokos", "ovca", "prase", "konj", "koza", "raca", "zajec", "mačka", "pes" ], "wild": [ "deer", "wolf", "bear", "fox", "boar", "eagle", "owl", "squirrel", "jelen", "volk", "medved", "lisica", "divji", "orel", "sova", "veverica" ], "infected": [ "zombie", "infected", "mutant", "corrupted", "okužen", "zombi", "mutiran" ] } # Environment categorization patterns ENVIRONMENT_PATTERNS = { "narava": [ "tree", "bush", "flower", "plant", "grass", "log", "stump", "vine", "drevo", "grm", "rož", "rastl", "trava", "hlod", "panj", "vino" ], "rudnik": [ "rock", "stone", "ore", "mineral", "crystal", "cave", "mine", "kamen", "skala", "ruda", "kristal", "jama", "rudnik" ], "tla": [ "ground", "dirt", "path", "road", "soil", "sand", "mud", "zemlja", "pot", "cesta", "pesek", "blato", "tile" ], "gradnja": [ "house", "barn", "shed", "building", "construction", "fence", "wall", "hiša", "skedenj", "skladišče", "zgradba", "ograja", "zid", "base" ] } def get_animal_category(filename): """Determine animal category from filename""" fname_lower = filename.lower() for category, patterns in ANIMAL_PATTERNS.items(): for pattern in patterns: if pattern in fname_lower: return category return None def get_environment_category(filename): """Determine environment category from filename""" fname_lower = filename.lower() for category, patterns in ENVIRONMENT_PATTERNS.items(): for pattern in patterns: if pattern in fname_lower: return category return None def organize_animals(): """Organize animal images""" if not OLD_ANIMALS.exists(): print("⚠️ zivali/ folder not found") return 0 print("\n🐕 ORGANIZING ANIMALS...") moved = 0 for file_path in OLD_ANIMALS.rglob("*.png"): category = get_animal_category(file_path.name) if category: dest_dir = ANIMALS_DIR / category dest_dir.mkdir(parents=True, exist_ok=True) dest_path = dest_dir / file_path.name if not dest_path.exists(): try: shutil.move(str(file_path), str(dest_path)) print(f" 📁 {file_path.name} → animals/{category}/") moved += 1 except Exception as e: print(f" ❌ Error: {e}") else: # Unknown animal - put in wild as default dest_dir = ANIMALS_DIR / "wild" dest_dir.mkdir(parents=True, exist_ok=True) dest_path = dest_dir / file_path.name if not dest_path.exists(): try: shutil.move(str(file_path), str(dest_path)) print(f" 📁 {file_path.name} → animals/wild/ (default)") moved += 1 except Exception as e: print(f" ❌ Error: {e}") return moved def organize_environment(): """Organize environment images""" print("\n🏞️ ORGANIZING ENVIRONMENT...") moved = 0 sources = [ (OLD_ENVIRONMENT, "okolje"), (OLD_TERRAIN, "teren"), (OLD_DECORATIONS, "dekoracije") ] for source_dir, source_name in sources: if not source_dir.exists(): continue print(f"\n Processing {source_name}/...") for file_path in source_dir.rglob("*.png"): category = get_environment_category(file_path.name) if category: dest_dir = ENV_DIR / category else: # Default to narava for decorations, tla for terrain if source_name == "teren": dest_dir = ENV_DIR / "tla" else: dest_dir = ENV_DIR / "narava" dest_dir.mkdir(parents=True, exist_ok=True) dest_path = dest_dir / file_path.name if not dest_path.exists(): try: shutil.move(str(file_path), str(dest_path)) print(f" 📁 {file_path.name} → environment/{dest_dir.name}/") moved += 1 except Exception as e: print(f" ❌ Error: {e}") return moved def main(): print("🗂️ ASSET ORGANIZATION SCRIPT") print("="*60) animals_moved = organize_animals() env_moved = organize_environment() print(f"\n{'='*60}") print(f"✅ Animals moved: {animals_moved}") print(f"✅ Environment moved: {env_moved}") print(f"📦 TOTAL: {animals_moved + env_moved} files organized") print(f"{'='*60}\n") if __name__ == "__main__": main() print("✨ Done!")