import os import shutil import re TARGET_DIR = "assets/slike/animations" # Classification Rules (Order matters) RULES = [ # Animals / Mutants (r"(rabbit|zajec)", "Zivali_Mutanti/Zajec"), (r"(sheep|ovca)", "Zivali_Mutanti/Ovca"), (r"(chicken|kokos|kokoš)", "Zivali_Mutanti/Kokos"), (r"(pig|prašič|svinja)", "Zivali_Mutanti/Prasic"), (r"(cow|krava)", "Zivali_Mutanti/Krava"), # Zombie Types (r"(miner|rudar)", "Zombiji/Rudar"), (r"(spitter|pljuvalec)", "Zombiji/Pljuvalec"), (r"(boss|velikan)", "Zombiji/Boss"), (r"(runner|tekac)", "Zombiji/Tekac"), (r"(crawler|plazilec)", "Zombiji/Plazilec"), (r"(weak|navaden)", "Zombiji/Navadni"), # Generic Zombie fallback (r"(zombie|undead)", "Zombiji/Ostalo"), # Other (r".*", "Nerazvrsceno") ] def organize_anims(): print(f"🚀 ORGANIZING ANIMATIONS in {TARGET_DIR}...") if not os.path.exists(TARGET_DIR): print("❌ Directory not found.") return moved_count = 0 # Get all files first files = [f for f in os.listdir(TARGET_DIR) if os.path.isfile(os.path.join(TARGET_DIR, f))] for filename in files: if not filename.lower().endswith(('.png', '.jpg')): continue fname_lower = filename.lower() target_sub = "Nerazvrsceno" # Match rules for pattern, folder in RULES: if re.search(pattern, fname_lower): target_sub = folder break # Move dest_dir = os.path.join(TARGET_DIR, target_sub) if not os.path.exists(dest_dir): os.makedirs(dest_dir) src = os.path.join(TARGET_DIR, filename) dst = os.path.join(dest_dir, filename) try: shutil.move(src, dst) moved_count += 1 except Exception as e: print(f"Error {filename}: {e}") print("="*40) print(f"✅ ANIMATIONS ORGANIZED. Moved {moved_count} files.") print("="*40) # Print summary for root, dirs, files in os.walk(TARGET_DIR): # Don't print root if root == TARGET_DIR: continue rel = os.path.relpath(root, TARGET_DIR) count = len([f for f in files if f.endswith('.png')]) if count > 0: print(f" 📂 {rel}: {count}") if __name__ == "__main__": organize_anims()