#!/usr/bin/env python3 """ āš’ļø COMPLETE TOOL ORGANIZATION SCRIPT Find ALL tools anywhere in assets/slike/ and organize by material tier """ import os import shutil from pathlib import Path # Base directories BASE_DIR = Path("/Users/davidkotnik/repos/novafarma/assets/slike") TOOLS_DIR = BASE_DIR / "items" / "tools" # Tool types to look for TOOL_TYPES = [ "hoe", "shovel", "scythe", "watering_can", "axe", "pickaxe", "fishing_rod", "fishing_net", "hammer", "wrench", "saw", "sickle", "bucket", "pitchfork" ] # Material tiers (order matters - check basic first!) MATERIAL_TIERS = { "wood": ["wood_", "wooden_"], "stone": ["stone_", "basic_", "hoe_basic", "shovel_basic", "rusty_"], # basic = stone tier "iron": ["iron_"], "gold": ["steel_", "gold_"], "special": ["fishing_", "hammer_", "wrench_", "baking_", "piercing_", "bucket_", "compass_", "hourglass_", "saw_", "scissors_", "tool_rack", "tool_shed", "tool_durability", "tool_break", "tool_icons", "repair_bench"] } def get_tool_tier(filename): """Determine which material tier a tool belongs to""" fname_lower = filename.lower() # Check if it's a tool at all is_tool = any(tool_type in fname_lower for tool_type in TOOL_TYPES) is_tool = is_tool or "tool_" in fname_lower or "orodja" in fname_lower if not is_tool: return None # Determine tier for tier, patterns in MATERIAL_TIERS.items(): for pattern in patterns: if pattern in fname_lower: return tier # Default: if it has "tool" in name but no tier, put in special if "tool" in fname_lower or "orodja" in fname_lower: return "special" return None def find_all_tools(base_dir): """Find all tool files in the entire directory tree""" tools_found = [] print(f"šŸ” Scanning {base_dir} for tools...") for file_path in base_dir.rglob("*.png"): if file_path.is_file(): tier = get_tool_tier(file_path.name) if tier: # Skip if already in correct location if file_path.parent == (TOOLS_DIR / tier): continue tools_found.append((file_path, tier)) return tools_found def organize_tools(): """Main organization function""" print("āš’ļø COMPLETE TOOL ORGANIZATION") print("="*60) # Create tier directories for tier in MATERIAL_TIERS.keys(): tier_dir = TOOLS_DIR / tier tier_dir.mkdir(parents=True, exist_ok=True) # Find all tools tools = find_all_tools(BASE_DIR) if not tools: print("āœ… All tools are already organized!") return print(f"\nšŸ“¦ Found {len(tools)} tools to organize\n") # Organize by tier moved_count = 0 tier_counts = {tier: 0 for tier in MATERIAL_TIERS.keys()} for file_path, tier in tools: dest_dir = TOOLS_DIR / tier dest_path = dest_dir / file_path.name # Check if destination already exists if dest_path.exists(): print(f"āš ļø Skipping {file_path.name} (already exists in {tier}/)") continue # Move file try: shutil.move(str(file_path), str(dest_path)) print(f"šŸ“ {file_path.name} → tools/{tier}/") moved_count += 1 tier_counts[tier] += 1 except Exception as e: print(f"āŒ Error moving {file_path.name}: {e}") # Summary print(f"\n{'='*60}") print(f"āœ… Moved: {moved_count} tools") print(f"\nBreakdown by tier:") for tier, count in tier_counts.items(): if count > 0: print(f" • {tier:10} : {count} tools") print(f"{'='*60}\n") if __name__ == "__main__": organize_tools() print("✨ Done!")