#!/usr/bin/env python3 """ Organizira slike v Slike_za_Tiled/ mapi v kategorije """ import os import shutil from pathlib import Path # Bazna mapa BASE_DIR = Path("/Users/davidkotnik/Desktop/novafarma/Slike_za_Tiled") # Definicije kategorij (ključne besede -> ciljna mapa) CATEGORIES = { "01_characters/zombies": ["zombie"], "01_characters/npcs": ["npc", "trader", "blacksmith", "merchant", "baker", "farmer", "doctor", "ivan", "jakob", "marija", "lena", "sonya", "romance"], "01_characters/players": ["kai_character", "ana_character", "character_customization"], "02_creatures/animals": ["animal", "cow", "chicken", "dog", "livestock", "donkey", "horse"], "02_creatures/monsters": ["troll", "creature", "anomalous", "cryptid", "mythical_creatures"], "02_creatures/slimes": ["slime"], "02_creatures/dinosaurs": ["dinosaur", "dino"], "03_terrain/ground": ["grass", "soil", "tileset", "ground", "terrain"], "03_terrain/fences": ["fence"], "03_terrain/mine": ["mine_tileset", "mine_interior", "mine_entrance"], "04_buildings/houses": ["house", "farmhouse", "barn"], "04_buildings/ruins": ["ruin", "buildings_ruins"], "04_buildings/structures": ["building", "town_buildings", "structure", "blacksmith_workshop", "bridge", "wall", "city", "portal", "minting"], "05_objects/tools": ["tool", "weapon", "bow", "arrow", "firearms"], "05_objects/furniture": ["furniture", "bathroom", "bedroom", "kitchen", "living_room"], "05_objects/items": ["items_pack", "backpack", "chest", "grave", "spawner", "objects_pack"], "05_objects/farming": ["sprinkler", "seed", "crop"], "06_vegetation/trees": ["tree", "sequoia", "birch", "vegetation"], "06_vegetation/plants": ["flower", "plant", "leaf"], "07_dlc_content/amazon": ["amazon"], "07_dlc_content/atlantis": ["atlantis"], "07_dlc_content/catacombs": ["catacombs"], "07_dlc_content/chernobyl": ["chernobyl"], "07_dlc_content/desert_egypt": ["egyptian", "egypt", "pyramid", "sphinx"], "07_dlc_content/lochness": ["lochness"], "07_dlc_content/mythical": ["mythical_pack"], } def create_directories(): """Ustvari vse potrebne direktorije""" print("🔨 Ustvarjam direktorije...") for category in CATEGORIES.keys(): dir_path = BASE_DIR / category dir_path.mkdir(parents=True, exist_ok=True) print(f" ✓ {category}") # Tudi misc (BASE_DIR / "08_misc").mkdir(parents=True, exist_ok=True) print(f" ✓ 08_misc") print() def organize_images(): """Organizira slike v kategorije""" print("📦 Organiziram slike...") # Pridobi vse PNG slike v baznem direktoriju (samo top-level) png_files = list(BASE_DIR.glob("*.png")) total_files = len(png_files) moved_files = 0 print(f"Najdenih {total_files} PNG datotek\n") # Slovar za sledenje premikom moved_to_category = {} for png_file in png_files: filename = png_file.name.lower() moved = False # Preveri vsako kategorijo for category, keywords in CATEGORIES.items(): if any(keyword in filename for keyword in keywords): target_dir = BASE_DIR / category target_file = target_dir / png_file.name # Premakni datoteko shutil.move(str(png_file), str(target_file)) if category not in moved_to_category: moved_to_category[category] = 0 moved_to_category[category] += 1 moved_files += 1 moved = True break # Če ni ujemanja, premakni v misc if not moved: target_dir = BASE_DIR / "08_misc" target_file = target_dir / png_file.name shutil.move(str(png_file), str(target_file)) if "08_misc" not in moved_to_category: moved_to_category["08_misc"] = 0 moved_to_category["08_misc"] += 1 moved_files += 1 print("\n✅ Organizacija končana!\n") print("📊 Statistika premikov:") for category, count in sorted(moved_to_category.items()): print(f" {category}: {count} datotek") print(f"\n🎉 Skupaj premaknjenih: {moved_files} / {total_files}") if __name__ == "__main__": print("=" * 60) print(" ORGANIZACIJA SLIK - NovaFarma") print("=" * 60) print() create_directories() organize_images() print("\n" + "=" * 60) print(" KONČANO!") print("=" * 60)